One model and Many edit views
Posted
by
user179438
on Stack Overflow
See other posts from Stack Overflow
or by user179438
Published on 2010-12-23T17:50:02Z
Indexed on
2010/12/23
17:54 UTC
Read the original article
Hit count: 179
ruby-on-rails
Hi, I have a model I named User, and I want use two different Views to edit it: the usual edit view and another view I called edit_profile.
I had no problem in creating routing, controller and views: I added edit_profile and update_profile views, and I added on routes.rb the line:
map.resources :users ,:member => {:edit_profile => :get, :update_profile => :put}
The problem is: when I submit the form in edit_profile and some error occur in some input fields, rails reload the edit_path page instead of edit_profile_path page ! This is the form on edit_profile.html.erb
form_for(:user, @user, :url => {:action => :update_profile}, :html => { :method => :put} ) do |f|
= f.text_field :description
= f.text_area :description
= f.error_message_on :description
....
....
= f.submit 'Update profile'
After clicking Update profile, if input errors occur I want to show edit_profile view instead of edit view
Do You have some ideas ? many thanks
© Stack Overflow or respective owner