diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 3308601..d8ce621 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -11,4 +11,10 @@ class MoviesController < ApplicationController def edit @movie = Movie.find(params[:id]) end + def update + @movie = Movie.find(params[:id]) + movie_params = params.require(:movie).permit(:title, :description, :rating, :released_on, :total_gross) + @movie.update(movie_params) + redirect_to @movie + end end diff --git a/config/routes.rb b/config/routes.rb index 68b3d10..210108c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,5 +2,6 @@ Rails.application.routes.draw do root "movies#index" get "movies" => "movies#index" get "movies/:id" => "movies#show", as: "movie" + patch "movies/:id" => "movies#update" get "movies/:id/edit" => "movies#edit", as: "edit_movie" end