Skip to content

Commit c2dab8c

Browse files
committed
watchlist
1 parent c792d95 commit c2dab8c

11 files changed

+72
-1
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ gem "bootstrap", "~> 5.2"
4040
# gem "kredis"
4141
gem "autoprefixer-rails"
4242

43-
43+
gem 'faker'
4444
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
4545
# gem "bcrypt", "~> 3.1.7"
4646

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ GEM
9999
error_highlight (0.5.1)
100100
erubi (1.12.0)
101101
execjs (2.9.1)
102+
faker (3.2.1)
103+
i18n (>= 1.8.11, < 2)
102104
ffi (1.16.3)
103105
font-awesome-sass (6.4.2)
104106
sassc (~> 2.0)
@@ -263,6 +265,7 @@ DEPENDENCIES
263265
bootstrap (~> 5.2)
264266
debug
265267
error_highlight (>= 0.4.0)
268+
faker
266269
font-awesome-sass (~> 6.1)
267270
importmap-rails
268271
jbuilder

app/controllers/lists_controller.rb

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class ListsController < ApplicationController
2+
def new
3+
@list = List.new
4+
end
5+
6+
def create
7+
@list = List.new(list_params)
8+
if @list.save
9+
# Handle the successful save (e.g., redirect to a 'thank you' page)
10+
redirect_to lists_path
11+
else
12+
render :new, status: :unprocessable_entity
13+
end
14+
end
15+
16+
def index
17+
@lists = List.all
18+
end
19+
20+
def show
21+
end
22+
end
23+
24+
private
25+
26+
def list_params
27+
params.require(:list).permit(:name)
28+
# Include other parameters as necessary
29+
end

app/helpers/lists_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ListsHelper
2+
end

app/helpers/movies_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module MoviesHelper
2+
end

app/views/lists/create.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Lists#create</h1>
2+
<p>Find me in app/views/lists/create.html.erb</p>

app/views/lists/index.html.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div class="container mt-5">
2+
<h1>lists of movies</h1>
3+
<p><% @lists.each do |list| %></p>
4+
<%= list.name %>
5+
<% end %>
6+
7+
<%= link_to "create new list", new_list_path, class: "btn btn-primary" %>
8+
</div>

app/views/lists/new.html.erb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<%= simple_form_for @list do |f| %>
2+
<%= f.input :name, placeholder: "classic" %>
3+
<%= f.button :submit, class: "btn btn-primary" %>
4+
<% end %>

app/views/lists/show.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Lists#show</h1>
2+
<p>Find me in app/views/lists/show.html.erb</p>

config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77

88
# Defines the root path route ("/")
99
# root "posts#index"
10+
resources :lists, only: [:show, :new, :create, :index]
1011
end

db/seeds.rb

+18
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,21 @@
77
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
88
# MovieGenre.find_or_create_by!(name: genre_name)
99
# end
10+
11+
puts 'Clearing database'
12+
13+
Movie.destroy_all
14+
15+
puts 'database cleared'
16+
17+
wonder_woman_1984 = Movie.create(title: "Wonder Woman 1984", overview: "Wonder Woman comes into conflict with the Soviet Union during the Cold War in the 1980s", poster_url: "https://image.tmdb.org/t/p/original/8UlWHLMpgZm9bx6QYh0NFoq67TZ.jpg", rating: 6.9)
18+
wonder_woman_1984.save
19+
the_shawshank_redemption = Movie.create(title: "The Shawshank Redemption", overview: "Framed in the 1940s for double murder, upstanding banker Andy Dufresne begins a new life at the Shawshank prison", poster_url: "https://image.tmdb.org/t/p/original/q6y0Go1tsGEsmtFryDOJo3dEmqu.jpg", rating: 8.7)
20+
the_shawshank_redemption.save
21+
titanic = Movie.create(title: "Titanic", overview: "101-year-old Rose DeWitt Bukater tells the story of her life aboard the Titanic.", poster_url: "https://image.tmdb.org/t/p/original/9xjZS2rlVxm8SFx8kPC3aIGCOYQ.jpg", rating: 7.9)
22+
titanic.save
23+
oceans_eight = Movie.create(title: "Ocean's Eight", overview: "Debbie Ocean, a criminal mastermind, gathers a crew of female thieves to pull off the heist of the century.", poster_url: "https://image.tmdb.org/t/p/original/MvYpKlpFukTivnlBhizGbkAe3v.jpg", rating: 7.0)
24+
oceans_eight.save
25+
26+
list_1 = List.create(name: "classic movies")
27+
list_2 = List.create(name: "thriller movies")

0 commit comments

Comments
 (0)