Hey Everyone,
I'm new to Rails and working through the book Simply Rails 2. I've
just hit one of my first large snags.
This *was* my routes file:
map.resources :stories, :has_many => :votes, :collection => { :bin
=> :get }
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
map.resource :session
map.root :controller => 'stories'
map.resources :users
my problem was anytime I traveled to the url /users/1-username/ i got
an error saying the only action was 'show'
Which did and did not make sense to me. It did make sense becuase the
only action in my controller was show. and in both theory (and I tried
it and it worked) the url should be /users/show/1-username. Which
worked without a problem. But of course the book only user the /users/
1-username/ url.
So after some time i changed my routes file to:
map.resources :users
map.resources :stories, :has_many => :votes, :collection => { :bin
=> :get }
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
map.resource :session
map.root :controller => 'stories'
Which fixed my problem. I can now access /users/1-username/ as
expected (displays user information).
But I really don't understand why. Why is it now the controller is
defaulting to it's only action but before it was not?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---