Ptx wrote:
Hello
I am a Ruby newbie, thus a rather simple question. My list view shows table records and enables user to click a button in order to change value of one attribute in given record. I use this code to invoke a method from controller:
<%= button_to "Change", { :action => "edit", :id => prog.id_prog } %>
My method looks like this (just a simple one - to set the salary attribute to 1000)
def edit prog = Prog.find(params[:id]) prog.update_attribute(:salary, 1000)
redirect_to :action => 'list' end
However after a list view is shown again the change is not made to the database. I do not get it, as find returns the proper record and update_attribute returns true. What may be wrong?
Thanks in advance
I believe you need a 'prog.save' in there, before the redirect_to