0

I had been playing with my rails app for a few days and the server seemed to be working fine. I could edit pages and reload the browser and see the rendered page or an error trace in the browser.

By the way I am using Ruby 1.9.3 and Rails 4.0.2 through the Ruby & Rails bash downloaded in executable from the railsinstaller website. Also I'm using Chrome on Windows 8.

Now when I type "rails server" in the console, the server appears to boot up fine for a few seconds before giving me a trace. The browser won't display any part of the rails app on localhost:3000, not even an error trace. I get an error trace in the console, though.

I don't know how to copy and paste text from the Windows command line so I took two screenshots of the error trace. I don't have enough reputation to post them here, so here they are on imgur:

https://i.stack.imgur.com/885m8.jpg


edit:

In light of the information on this page: Why is my development server not loading? default_controller_and_action': missing :action (ArgumentError) I am refactoring my routes.rb code. I just replaced the code with:

  root :to => 'center#index'

  post "items" => 'center#create_item_orphan'

  post "users" => 'center#create_user'

  get "center/show_user/" => 'center#show_user'

  post "/center/create_item_owned" => 'center#create_item_owned'

and the server appears to be working but I will report on the results.

While what I had before was

root 'center#index'

  post "/items" => 'center#create_item_orphan'

  post "/users" => 'center#create_user'

  get "/center/show_user/"

  post "/center/create_item_owned"

I am not sure in particular what fixed it because there were a number of changes to the routes, as you can see.


The server is working now! Now it is time for me to trudge through the stream of errors I will encounter in the browser. Stay tuned for more questions and thanks for your help. Also, I can't mark the question as solved quite yet.

Community
  • 1
  • 1

1 Answers1

0

The difference between your two routes files is that Rails doesn't know how to imply a controller/action for this route:

get "/center/show_user/"

So you have to tell it:

get "/center/show_user", :to => "center#show_user"
Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
  • Alright, thanks, I was confused about that. I was pretty certain that in the default routes.rb for a brand new rails app, there was a line with the syntax `get "foo\bar"` or something like that (but just `get` + `address`, nothing else) – user3432433 Mar 19 '14 at 00:32
  • IMHO problem was due to the last `/` after `show_user`, Rails tried to imply the controller#action from the route but failed as it got confused with the extra `/` and thought that you missed to give an action after it. Hence, the error. You can use the shortcut route, both `get "/center/show_user"` or `get "center/show_user"` should work and map to `center#show_user` plus create a named route `center_show_user_path`. – Kirti Thorat Mar 19 '14 at 02:05