Skip to content

Instantly share code, notes, and snippets.

@tarolandia
Created October 11, 2011 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarolandia/1279572 to your computer and use it in GitHub Desktop.
Save tarolandia/1279572 to your computer and use it in GitHub Desktop.
Edit todo item
...
def edit
@todo = Todo.find(params[:id])
if @todo.nil?
flash[:notice] = "Empty item"
redirect_to :action => 'index'
end
end
def update
@todo = Todo.find(params[:id])
if @todo.update_attributes params[:todo]
flash[:notice] = 'Item edited'
redirect_to :action => 'index'
else
render "edit"
end
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment