Skip to content

Instantly share code, notes, and snippets.

@Abhishek-Ravichandran
Forked from armandofox/edit_update.rb
Last active December 7, 2016 05:30
Show Gist options
  • Save Abhishek-Ravichandran/de42bcea59e180b0744fa0917fb45b32 to your computer and use it in GitHub Desktop.
Save Abhishek-Ravichandran/de42bcea59e180b0744fa0917fb45b32 to your computer and use it in GitHub Desktop.
edit_update.rb
# in movies_controller.rb
def edit
@movie = Movie.find params[:id]
end
def update
@movie = Movie.find params[:id]
permitted = params[:movie].permit(:title, :rating, :description, :release_date)
@movie.update_attributes!(permitted)
flash[:notice] = "#{@movie.title} was successfully updated."
redirect_to movie_path(@movie)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment