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