diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 70d719e..575df53 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -30,6 +30,6 @@ class MoviesController < ApplicationController private def movie_params - params.require(:movie).permit(:title, :description, :rating, :released_on, :total_gross) + params.require(:movie).permit(:title, :description, :rating, :released_on, :total_gross, :director, :duration, :image_file_name) end end diff --git a/app/views/movies/_form.html.erb b/app/views/movies/_form.html.erb index 17cbca9..0d50b62 100644 --- a/app/views/movies/_form.html.erb +++ b/app/views/movies/_form.html.erb @@ -14,5 +14,14 @@ <%= f.label :total_gross %> <%= f.number_field :total_gross %> + <%= f.label :director %> + <%= f.text_field :director %> + + <%= f.label :duration %> + <%= f.text_field :duration %> + + <%= f.label :image_file_name %> + <%= f.text_field :image_file_name %> + <%= f.submit %> <% end %> diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb index b75de10..b03bf33 100644 --- a/app/views/movies/index.html.erb +++ b/app/views/movies/index.html.erb @@ -1,23 +1,25 @@
- - -
- <%= link_to "Add New Movie", new_movie_path, class: "button" %> + +
+ <%= link_to "Add New Movie", new_movie_path, class: "button" %> +
diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index 011fe23..d54d205 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -1,4 +1,7 @@
+
+ <%= image_tag @movie.image_file_name %> +

<%= @movie.title %>

@@ -8,6 +11,14 @@ <%= @movie.description %>

+ + + + + + + + diff --git a/db/migrate/20230925205851_add_more_fields_to_movies.rb b/db/migrate/20230925205851_add_more_fields_to_movies.rb new file mode 100644 index 0000000..7a15a2a --- /dev/null +++ b/db/migrate/20230925205851_add_more_fields_to_movies.rb @@ -0,0 +1,7 @@ +class AddMoreFieldsToMovies < ActiveRecord::Migration[7.0] + def change + add_column :movies, :director, :string + add_column :movies, :duration, :string + add_column :movies, :image_file_name, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 7254875..d292225 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_25_183426) do +ActiveRecord::Schema[7.0].define(version: 2023_09_25_205851) do create_table "movies", force: :cascade do |t| t.string "title" t.string "rating" @@ -19,6 +19,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_25_183426) do t.datetime "updated_at", null: false t.text "description" t.date "released_on" + t.string "director" + t.string "duration" + t.string "image_file_name" end end
Director:<%= @movie.director %>
Duration:<%= @movie.duration %>
Total Gross: <%= total_gross(@movie) %>