Complete Lesson 12 Part 2

This commit is contained in:
Simon Quigley 2023-09-25 15:28:26 -05:00
parent b6237c5daa
commit 2b32bc0e62
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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