ruby - Rails update_attributes always redirects -


i'm writing edit page record in database, want redirect if update successful , render edit page again errors. here code:

def edit     @list = list.find(params[:id])      if @list.update_attributes(params[:list])         redirect_to(root_path)     else         render('edit')     end end 

the redirect fires launch edit page, before changes made or submit button clicked.

any ideas appreciated.

your edit action should this:

def edit   @list = list.find(params[:id]) end 

it renders edit view. form should point (and is) update action should so:

def update   @list = list.find(params[:id])    if @list.update_attributes(params[:list])       redirect_to(root_path)   else       render :edit   end end 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -