Complete Lesson 12 Part 2

main
Simon Quigley 1 year ago
parent b6237c5daa
commit 2b32bc0e62

@ -11,4 +11,10 @@ class MoviesController < ApplicationController
def edit def edit
@movie = Movie.find(params[:id]) @movie = Movie.find(params[:id])
end 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 end

@ -2,5 +2,6 @@ Rails.application.routes.draw do
root "movies#index" root "movies#index"
get "movies" => "movies#index" get "movies" => "movies#index"
get "movies/:id" => "movies#show", as: "movie" get "movies/:id" => "movies#show", as: "movie"
patch "movies/:id" => "movies#update"
get "movies/:id/edit" => "movies#edit", as: "edit_movie" get "movies/:id/edit" => "movies#edit", as: "edit_movie"
end end

Loading…
Cancel
Save