Complete Lesson 20
This commit is contained in:
parent
1656289d7d
commit
41095dc0e3
@ -11,7 +11,7 @@ class MoviesController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
@movie = Movie.find(params[:id])
|
@movie = Movie.find(params[:id])
|
||||||
if @movie.update(movie_params)
|
if @movie.update(movie_params)
|
||||||
redirect_to @movie
|
redirect_to @movie, notice: "Movie successfully updated!"
|
||||||
else
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
@ -22,15 +22,16 @@ class MoviesController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@movie = Movie.new(movie_params)
|
@movie = Movie.new(movie_params)
|
||||||
if @movie.save
|
if @movie.save
|
||||||
redirect_to @movie
|
redirect_to @movie, notice: "Movie successfully created!"
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def destroy
|
def destroy
|
||||||
@movie = Movie.find(params[:id])
|
@movie = Movie.find(params[:id])
|
||||||
@movie.destroy
|
if @movie.destroy
|
||||||
redirect_to movies_url, status: :see_other
|
redirect_to movies_url, status: :see_other, alert: "Movie successfully destroyed!"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
11
app/views/layouts/_flash.html.erb
Normal file
11
app/views/layouts/_flash.html.erb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<% if flash[:notice] %>
|
||||||
|
<div class="flash notice">
|
||||||
|
<%= flash[:notice] %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if flash[:alert] %>
|
||||||
|
<div class="flash alert">
|
||||||
|
<%= flash[:alert] %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
@ -14,6 +14,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<%= render "layouts/header" %>
|
<%= render "layouts/header" %>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<%= render "layouts/flash" %>
|
||||||
|
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</div>
|
||||||
<%= render "layouts/footer" %>
|
<%= render "layouts/footer" %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user