diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d1..6b4dcfa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,3 @@ class ApplicationController < ActionController::Base + before_action :authenticate_user! end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 13820e3..d98d7fd 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,4 +1,6 @@ class MoviesController < ApplicationController + before_action :set_movie, only: [:show, :edit, :update, :destroy] + def new @movie = Movie.new end @@ -14,12 +16,9 @@ def index end def show - @movie = Movie.find(params.fetch(:id)) end def create - movie_params = params.require(:movie).permit(:title, :description) - @movie = Movie.new(movie_params) if @movie.valid? @@ -32,14 +31,9 @@ def create end def edit - @movie = Movie.find(params.fetch(:id)) end def update - @movie = Movie.find(params.fetch(:id)) - - movie_params = params.require(:movie).permit(:title, :description) - if @movie.update(movie_params) redirect_to @movie, notice: "Movie updated successfully." else @@ -48,10 +42,18 @@ def update end def destroy - @movie = Movie.find(params.fetch(:id)) - @movie.destroy redirect_to movies_url, notice: "Movie deleted successfully." end + + private + + def movie_params + movie_params = params.require(:movie).permit(:title, :description) + end + + def set_movie + @movie = Movie.find(params.fetch(:id)) + end end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..1233c26 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,26 @@ +# == Schema Information +# +# Table name: users +# +# id :bigint not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# first_name :string +# last_name :string +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email (email) UNIQUE +# index_users_on_reset_password_token (reset_password_token) UNIQUE +# +class User < ApplicationRecord + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :validatable +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e19b841..fe2cf70 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,19 +6,19 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> + <%= render "shared/cdn_assets" %> + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %>
-