diff --git a/app/assets/javascripts/movies.js b/app/assets/javascripts/movies.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/movies.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/movies.scss b/app/assets/stylesheets/movies.scss new file mode 100644 index 0000000..b86dfed --- /dev/null +++ b/app/assets/stylesheets/movies.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Movies controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb new file mode 100644 index 0000000..bc2192b --- /dev/null +++ b/app/controllers/movies_controller.rb @@ -0,0 +1,48 @@ +class MoviesController < ApplicationController + def index + @movies = Movie.all + end + + def show + @movie = Movie.find(params[:id]) + end + + def new + @movie = Movie.new + end + + def create + @movie = Movie.new(movie_params) + if @movie.save + redirect_to @movie + else + render 'new' + end + + end + + def edit + @movie = Movie.find(params[:id]) + end + + def update + @movie = Movie.find(params[:id]) + if @movie.update(movie_params) + redirect_to(@movie) + else + render "edit" + end + end + + def destroy + @movie =Movie.find(params[:id]) + @movie.destroy + redirect_to movies_path + end + + private + def movie_params + params.require(:movie).permit(:title,:date ,:director , :description , :country) + + end +end diff --git a/app/helpers/movies_helper.rb b/app/helpers/movies_helper.rb new file mode 100644 index 0000000..493eee5 --- /dev/null +++ b/app/helpers/movies_helper.rb @@ -0,0 +1,2 @@ +module MoviesHelper +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 72827c6..f1c69ac 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,11 +8,25 @@
+