Wednesday, November 3, 2010

[Rails] Rails routing issue

Within a rails app I've got a special url (/profile) that I'm mapping
to the user controller to allow a user to view and edit their profile.
I made the following entries into my route file so that the "get" for
profile will route me to the profile action in the user controller and
the "post" for profile will route to the update_profile action in the
user controller.

match '/profile', :to => 'users#profile', :via => "get"
match '/profile', :to => 'users#update_profile', :via => "post"
If I run rake routes I see the following two entries

profile GET /profile(.:format) {:controller=>"users",
":action=>"profile"}
profile POST /profile(.:format) {:controller=>"users",
":action=>"update_profile"}
If I try hitting the dev url http://localhost:3000/profile it brings
up the profile page as expected. If I press the form button it gives
me the following error:

Routing Error

No route matches "/profile"
Looking at the generated html on the initial page I see the following
form tag, so it seems the action is correctly set.

<form accept-charset="UTF-8" action="/profile" class="edit_user"
enctype="multipart/form-data" id="edit_user_1" method="post">
So what am I missing? By looking at the rake routes output, I was
assuming this would work as is. Am I thinking about my http verbs
incorrectly? Any help would be appreciated.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate