In my edit page: url = profile/:id/edit the content is ! <%= form_for(@user, :as => :user, :url => profile_path(current_user), :html=>{:method => :put}) do |form| %> <%= form.text_field :email, :class=>"input"%> <%= form.submit ''Update Profile''%> <% end %> ............................ In controller section ! class ProfileController < ApplicationController def edit @user = User.find(params[:id]) end def update @user = User.find(params[:id]) @user.email = params[:user][:email] @user.save respond_to do |format| if @user.save = @user.update_attributes(params[:user]) if @user.update_attributes(params[:user]) format.html {redirect_to(profile_path(@user), :notice => ''User was successfully updated.'')} else format.html { render action: "index" } end end end ........... In Route ... match "/profile/:id" => "profile#index", :as => :profile match "/profile/:id/edit" => "profile#edit", :as => :profile_edit put ''/profile/:id'' => "profile#update" ## method = put for update ............... In Model - update data be saved in user table. ................. But I can''t update data . In rails server screen , I see the edit process.I can''t see update process - like " Update user where .........." Pls give me a hand!!!!!!! -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 April 2012 10:01, phoe san <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> ... > def update > > @user = User.find(params[:id]) > > -zEA56+9Y4QD6gbPvEgmw2w@public.gmane.org = params[:user][:email] > > -uQpvtAwYA0+zQB+pC5nmwQ@public.gmane.org > > > respond_to do |format| > > if @user.save = -lxvFfxMWJwjZ3kn0UGNW0g@public.gmane.org_attributes(params[:user]) > > if @user.update_attributes(params[:user]) > format.html {redirect_to(profile_path(@user), :notice => ''User > was successfully updated.'')} > else > format.html { render action: "index" } > end > end > end > ...........You need to look through the update method and ask yourself what each line is doing. For example you seem to have two save calls and also two update_attributes (which updates the object and saves it). That is four saves all together. is that what you meant to do? Then if it still does not work check in development.log to make sure the action is being called with the correct parameters, then if still not working debug into the update action to see what is going on. Have a look at the Rails Guide on Debugging if you do not know how to do that. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On Apr 6, 10:01 am, phoe san <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > In Route ... > > match "/profile/:id" => "profile#index", :as => :profile > match "/profile/:id/edit" => "profile#edit", :as => :profile_edit > put ''/profile/:id'' => "profile#update" ## method = put for updateYour update action looks a little confused - it''s updating the record 4 times which seems overkill, but it looks like you''re not ever getting to the update action - if you were an exception would be raised at the point where you do @user.save = ... (since there is no save= method) match (by default) accepts all http verbs, so when your put request comes through it gets routed to profile#index. routes are considered in the order they are defined, so although you do have a put specific route, rails never even looks at it because it finds match ''/ profile/:id'' first. You should either make the route to index action more specific (i.e. say that it has to be a GET) or move the route to the update index before it Fred> Pls give me a hand!!!!!!! > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Thank Fred! routes are considered in the order they are defined, so although you do have a put specific route, rails never even looks at it because it finds match ''/ profile/:id'' first...... This logic fix my error. phoesan -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.