I was just wondering: How can I identify which parameters is being updated in a classic CRUD controller?
I would like to redirect to different path depending on which parameters is being changed.
For example, if I have a Person with 3 attributes id name and firstname
In my controller:
def update
@person = Person.find(params[:id])
respond_to do |format|
if @person.update_attributes(params[:person])
#...
else
#...
end
end
end
How can I detect that name is being changed, and not firstname
Would something like !params[:name].nil? work?
Thanks for your help!
so you could check the params like you said. Something like
if !params.[:name].nil? ...OR
You could use the
_changed?methods