Hello,
I am relatively new to ruby on rails, so this question might be easy. Rails does a lot of magic and I am not sure where to look up such things, because I don't know which part of the framework is to blame.
I basically did the authlogic_example and fiddled around with the code afterwards. My routes.rb looks like this
map.root :controller => "user_session", :action => "new" # optional, this just sets the root route
map.resources :users
map.resource :user_session
As you can see, I have a controller called *user_session*. *user_session* has three actions new, create and destroy. I can reach the controllers at
localhost:3000/user_sessions/[new,destroy,create].
I can also reach the new action at
localhost:3000/user_session/new
for destroy or create I get a routing error here. According to the documentation the first case should be the standard one: "A singular name is given to map.resource. The default controller name is still taken from the plural name."
My problem now is that link_to only takes the singular of the controller name, where I can only reach new, but not destroy
<%= link_to "singular", :controller=>"user_session", :action=>"destroy" %>
#=> http://localhost:3000/user_session/destroy
<%= link_to "plural", :controller=>"user_sessions", :action=>"destroy" %>
#=> http://localhost:3000/user_session
This is pretty confusing and is not even close to what I expected, but also causes problems: I can't
redirect_to :controller=>"user_sessions", :action=>"destroy"
because I get redirected to
http://localhost:3000/user_session
As I already mentioned, I am pretty new to rails, so I might not have the right way of thinking yet. Can you point me to anything that describes this behaviour? How would I resolve this issue?