get "home/index"
I thought I'd get fancy also add a root controller and view for my website, so I coped that and slightly modified it to
root :to => "home/index"
Cool. Next, I went ahead and tried to generate a new scaffold for my first model, but uh oh, there was a problem!
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/mapper.rb:143:in `default_controller_and_action': missing :action (ArgumentError)
...
from /Users/.../Code/.../config/routes.rb:2
...
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands.rb:16
from script/rails:6:in `require'
from script/rails:6
My first reaction was, "!@# yet another problem with Rails 3 and my system," but after some searching for the error turned up nothing, I decided that I had probably screwed something up. Looking a little more closely at the stack trace of the error, I identified that the scaffold generation was in part based on code from my own app and not just the rails gems. Hmm, probabilities rising that I'm the culprit.
The error says that the default controller is missing an action. I checked out the gem, mapper.rb, and saw that it's parsing out some variable named "to" for a controller and action. I then opened up my routes.rb and saw that line of copied code, root :to => "home/index". I then thought back to the new rails syntax that I'd learned in the video tutorials and immediately realized my folly. One quick change,
root :to => "home#index"
and the generator is back to working. Although it can definitely be a pain dealing with open source software, it certainly is nice to be able to see the source of your problems.
thank´s
ReplyDeleteTHX!!! Saved a lot of time...
ReplyDeleteThat saved me a bunch of headaches. Thanks.
ReplyDeleteThank you so much!!! I would never have found that!!!
ReplyDeleteThanks for posting this! Saved me a ton of time when I got this error!
ReplyDeleteas above - thx for this
ReplyDeleteTHANKS!!!!
ReplyDeleteThank you very much!!!
ReplyDeleteBrilliant, thank you!
ReplyDeletethx!!! saved my evening
ReplyDeleteThey say 'Google is your friend' and it's true - because Google helped me find this. However, YOU provided the info. Google just indexed it.
ReplyDeleteTHANKS FOR SAVING ME SO MUCH TIME!
I love you.
ReplyDeleteThanks so much! So simple....
ReplyDeleteGreat help to me..Thanx!!
ReplyDeleteThank!
ReplyDeleteProblem solved in 20 sec... Thanks !
ReplyDeleteIf only every problem were that simple to solve! Thanks!
ReplyDeleteWish I had found this last week. Problem solved and made multiple attempts and countless hours debugging seem stupid. But thanks for the help, you have no idea how happy I am right now...
ReplyDeleteThanks man now it happened to me also but found the solution here thanks again
ReplyDeleteThanks, you nailed it! Exact same problem and resolution.
ReplyDeletefinally a solution! thank jebus its is not a rails problem!! thank you sir
ReplyDeleteU saved my time dude..
ReplyDeletesuch a minor mistake/ but was bugging me for an hour. FInally got it resolved.
Thank you once again :)