Rails route helpers are inexplicably prepending "postinstall" to requests - ruby-on-rails

* Listening on tcp://0.0.0.0:3000
Started GET "postinstall/" for 127.0.0.1 at 2013-10-27 07:26:15 +0000
ActiveRecord::SchemaMigration Load (1.8ms) SELECT "schema_migrations".* FROM "schema_migrations"
This is basically it, all my buttons linked to helpers like:
new_user_registration GET /users/sign_up(.:format) registrations#new
edit_user_registration GET /users/edit(.:format) registrations#edit
Only all the links are like this:
http://localhost:3000/postinstall/users/sign_in
I've been through my log and at one point requests just start being effectively poisoned by this "postinstall" business.
I've grepped for 'postinstall' because surely this word can't be coming from nowhere. I decided to sleep on it because I thought it must be a stupid mistake, but now I need help and unlike 99.9% of my previous questions - it doesn't seem this one has been answered whatsoever.
Searching for even the query "postinstall" on Google yields terrible results.
I THINK my problem lies in a path helper, everywhere the 'postinstall' is getting prepended to requests/urls - the path is referred to like so:
Test
<%= link_to "Sign In", new_user_session_path, :class => "btn btn-success" %>
Where the first link would work route OK, but then the buttons to Submit the login form are trying the POST to /postinstall/users/sign_in etc... The second button would be a link to /postinstall/users etc.
I have absolutely no idea how this started, I've been over my git log and even going back 3 or 4 days (this issue started last night) the error still persists.
Is it seemingly specific to my Mac too, deployed to a dev site (Ubuntu) with no issues. I have restarted my mac etc. Any help is very obviously appreciated...

I had the same problem.
I'm using puma as webserver, and puma uses a ENV called 'SCRIPT_NAME' which was setted with 'postinstall' value after i installed a software, doing puma inject 'postinstall' on url.
if you still having this issue, unset SCRIPT_NAME var from your ENV, using the command on shell unset SCRIPT_NAME.

If you are using TotalTerminal, the recent update leaves the SCRIPT_NAME environment variable set after the update. Rebooting the computer solves the issue.
I started a new topic on Binary Age's support site to try to get this fixed: http://discuss.binaryage.com/t/totalterminal-update-overrides-script-name-breaks-webservers/897

Related

ActionController::RoutingError in rails app using MRUJS and cablecar

Started GET "/node_modules/src/formSubmitDispatcher.ts" for ::1 at
2022-10-09 18:10:14 -0500 18:10:14 web.1 | 18:10:14 web.1 |
ActionController::RoutingError (No route matches [GET]
"/node_modules/src/formSubmitDispatcher.ts")
This is the error I see in the rails server. I do not see any error on the actual webpage an everything keeps working expect for the new feature I'm adding. It's a slideover form for adding comments to a blog using MRUJS/Cable Car. I have found the formSubmitDispatcher.ts file in the directory tree, but is located at /node_modules/mrujs/src/formSubmitDispatcher.ts. For some reason the path is wrong. Is there a way to fix this? This is not code that I wrote myself. It was generated as part of installing MRUJS. I'm happy to provide any relevant information, but as of right now I have no idea what that might be.

ActiveAdmin / Inherited Resources looking for invalid route when using nested resources. Only on server, not locally

I have a Rails 4 app using ActiveAdmin and nested resources. Everything is working fine on my local development version, but when I deploy to a server (Ubuntu LTS 12.04) I'm having a problem.
I have an ActiveAdmin configuration like:
ActiveAdmin.register Order do
belongs_to :user
end
This results in a path helper of admin_user_order_path. When trying to access the orders page (/admin/users/3/orders) I get an error saying route not valid, however it's looking for admin_user_user_order_path (note the additional user)
I've traced this back as far as I can, and I've found that at line 150 of inherited_resources/class_methods.rb self.parents_symbols already is [:user] - as a result, at line 167, it becomes [:user, :user] causing the problem.
So, as a very temporary solution, on the server I've manually added this at line 150:
self.parents_symbols = []
If I try the same thing locally (where it was otherwise working), that then breaks with a different error.
My mind is a bit fried now. Can anyone shed any light on this?

NoMethodError undefined method '-#' NoMethodError in Controller Ruby on Rails

Context:
I pulled the most recent code from the repository and tried to make sure that the changes I was about to push up were going to work with that version of the code. This is a Ruby on Rails application. Also worth noting is the fact that when running the main application that I pulled from on the web, this error does not show up. But if I run my branch or the main branch cloned onto my environment, the error always shows up for every url I try. So it is on my end.
Problem:
As soon as I go to localhost:3000, I get the following error:
NoMethodError in HomeController#index
undefined method `-#' for #<ActionDispatch::Response:0x64fd460>
What I've Tried:
I have asked my question on the #rubyonrails IRC channel and nobody was able to determine what was going on through the Full Trace (I haven't posted it here because I wasn't sure what was the best way to do that on here; it didn't look very good in the code block or block quote). I have looked at my HomeController's index method, which is defined as such:
def index
#groups = #current_user.groups
#things = Thing.where(:group_id => #groups.map{|e|e.id})
end
I have also Googled around and haven't found what I need to fix the problem.
What I've Learned So Far:
-# is an operator. Some people may receive a similar error in assuming that Ruby has the shortcut to
variable = variable + 1
that a lot of other languages have:
variable++
Here is an example of that case: Undefined method `+#' for false:FalseClass (NoMethodError) ruby
Question:
Does anyone have any further suggestions on how to find the issue here? Also, if I could easily put the Full Trace on here, formatted in an aesthetically pleasing manner, would someone tell me how? I'm at a loss with this one :(
Update (2/8/2013):
It seems that the issue does not necessarily reside in the HomeController nor home/index.html.erb View. I have attempted to access ANY url with a valid action and the same error occurs with "NoMethodError in..." changing to the corresponding [...]Controller#index.
Update (2/9/2013):
Since this error happens no matter what url I try to navigate to, I decided to look in the routes.rb file in the config folder. I ran my server through rubymine instead of the command line this time, which made it a little easier to read for me. I started looking through all the spit out and I noticed an interested line that consisted of:
["private-key looking thing"] [127.0.0.1] Started GET "/" for 127.0.0.1 at 2013-02-09 18:20:52 -0700
It seems like there is a syntactical error in routes.rb (that's my best guess at this point). This does not explain why this only is an issue on my local environment with the same code sets, but what else do I have to go off of?
Does anyone have any suggested things to be on the look out for while I sift through this file? Not really sure what to be looking for as far as errors are concerned. Rubymines inspection stuff converted all my double quotes to single quotes and doesn't really have anything else to complain about.
Thanks in advance,
Jake Smith
I am guessing it might as well be an syntactical error in the corresponding view page Home/index.html.haml .. I am suspecting there is unintended '-' in front of variable call. I tried to simulate a similar scenario in my rails platform and see following page on browser
undefined method `-#' for false:FalseClass
Correct lines of code
%h1 All Movies
= "filtervalue=#{#isFilterOld}"
= "Sortvalue=#{#isSortOld}"
Edited to simulate the error (observe the - in front of isFilterOld variable)
%h1 All Movies
= "filtervalue=#{-#isFilterOld}"
= "Sortvalue=#{#isSortOld}"
I have fixed the issue!
What fixed it:
Go to the directory where your gems are (for me that was C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1)
Delete all gems except for bundler
Make sure you delete the gems from the /cache/, /gems/, and /specifications/ folders (I just deleted them from the /gems/ folder at first and bundle install indicated that it could still find the gems)
Run bundle install
Further Inquiry:
Does anybody have any idea why this worked? I don't know if at this point I can narrow down which gem was causing the issue because the app is working now (I can visit all the urls with corresponding views). If the issue comes up again, I will delete gems one by one to nail down which one was at least causing the issue for me. But if anyone has any insight on this, a more detailed answer would be greatly appreciated by many more people than just me, I think. Thanks to all who helped thus far!

Rails params encoding with Passenger

I'm running an app (on Dreamhost) that works fine in the development environment, but does not work properly in production. I've tried eliminating every difference I could: using the same mysql instance, for example.
The only thing I can see is that my query params seem to be encoded strangely.
Here's how they look in the development instance:
This search:
GET "/individuals?utf8=%E2%9C%93&search%5Bfirstname_like%5D=&search%5Blastname_like%5D=jones&commit=Search"
Produces these params:
Parameters: {"utf8"=>"✓", "search"=>{"firstname_like"=>"", "lastname_like"=>"jones"}, "commit"=>"Search"}
In the production instance:
GET "/individuals/?utf8=%25E2%259C%2593&search%255Bfirstname_like%255D=&search%255Blastname_like%255D=jones&commit=Search"
Produces these params:
Parameters: {"commit"=>"Search", "search%5Bfirstname_like%5D"=>"", "utf8"=>"%E2%9C%93", "search%5Blastname_like%5D"=>"jones"}
The query string seems to have an extra "25" in there.
Any idea what gives?
Turns out this was an Apache "mod_rewrite" issue. I had a .htaccess file from html5boilerplate that was causing the problem.

in Ruby on Rails 2.3.2, how to print out params during a create action?

there is a scaffold created Story... and in the create action, there is
#story = Story.new(params[:story])
i was curious as to what is in params... so i want to dump out params... but there is no view associated with the create action... is there a way to dump out its content? is there a way to dump out the POST variables in of my code too? (to see what's going on in the lower level)
The easiest thing to do is just dump params out to the log:
Rails.logger.info("PARAMS: #{params.inspect}")
If you're in development mode, just look in your development.log and that line will be there.
The params scope is a combination of URL/FORM (GET/POST) fields, and it will be printed out in the log as part of the normal output processing, so you might not need your own dumping of it - any development or production log contains the params dump at the top of the log line, e.g.
Processing Clients::ClientsController#show (for x.x.x. at 2009-05-24 00:34:26) [GET]
Parameters: {"id"=>"303", "user_id"=>"2"}
Now I know Rails more, you can also simply use a
p params
in your code and look at the console's output (the log shown on the console)
If you're on a Mac, Spike is a great little app the analyses log files and will let you inspect params for requests, amongst other things.
Using Fiddler on Windows, it is shown
the HTTP line #1 is:
POST /stories HTTP/1.1
this is the POST content:
authenticity_token=62iw%2BrsxlCFsbnxsS7FXKRn6CcvJfjottrsBPlM5lZo%3D&story%5Bname%5D=Google+Main+Site&story%5Blink%5D=www.google.com&commit=Create
listed in a table:
authenticity_token 62iw+rsxlCFsbnxsS7FXKRn6CcvJfjottrsBPlM5lZo=
story[name] Google Main Site
story[link] www.google.com
commit Create
and the server log is:
Parameters: {"commit"=>"Create", "story"=>{"name"=>"Google Main Site", "link"=>"www.google.com"}, "authenticity_token"=>"62iw+rsxlCFsbnxsS7FXKRn6CcvJfjottrsBPlM5lZo="}
You don't need to anything except look in your logs (they live in /log). Unless you're fiddling with something, the logging of parameters is turned on by default in all logs.
Processing PostsController#create (for 127.0.0.1 at 2009-05-24 13:03:24) [POST]
Parameters: {"commit"=>"Create", "authenticity_token"=>"2G6BKOs8xNAaXiToVf4r1ko8QZzP9QAomi2PHVQC5Oc=", "story"=>{"something"=>"asdfafd"}}
Parameters lists all parameters, and the hash following "story" is the equivalent of params[:story] (everything comes to the server as strings, and Rails turns it into a HashWithIndifferentAccess so that you can access it with a symbol).
If you're on a *NIX system (including OS X) open a new terminal window/tab and type the following command:
tail -f log/development.log
You'll get a constant stream of requests coming in -- including params -- and the resulting DB actions. Invaluable for development/debugging, IMO.

Resources