Complete Lesson 21
This commit is contained in:
parent
41095dc0e3
commit
1a8d2c3e96
2
app/controllers/reviews_controller.rb
Normal file
2
app/controllers/reviews_controller.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class ReviewsController < ApplicationController
|
||||
end
|
2
app/helpers/reviews_helper.rb
Normal file
2
app/helpers/reviews_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module ReviewsHelper
|
||||
end
|
3
app/models/review.rb
Normal file
3
app/models/review.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class Review < ApplicationRecord
|
||||
belongs_to :movie
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
Rails.application.routes.draw do
|
||||
resources :reviews
|
||||
root "movies#index"
|
||||
|
||||
resources :movies
|
||||
|
12
db/migrate/20230926165701_create_reviews.rb
Normal file
12
db/migrate/20230926165701_create_reviews.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateReviews < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :reviews do |t|
|
||||
t.string :name
|
||||
t.integer :stars
|
||||
t.text :comment
|
||||
t.references :movie, null: false, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
13
db/schema.rb
generated
13
db/schema.rb
generated
@ -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_205851) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_09_26_165701) do
|
||||
create_table "movies", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.string "rating"
|
||||
@ -24,4 +24,15 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_25_205851) do
|
||||
t.string "image_file_name"
|
||||
end
|
||||
|
||||
create_table "reviews", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.integer "stars"
|
||||
t.text "comment"
|
||||
t.integer "movie_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["movie_id"], name: "index_reviews_on_movie_id"
|
||||
end
|
||||
|
||||
add_foreign_key "reviews", "movies"
|
||||
end
|
||||
|
7
test/controllers/reviews_controller_test.rb
Normal file
7
test/controllers/reviews_controller_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class ReviewsControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
13
test/fixtures/reviews.yml
vendored
Normal file
13
test/fixtures/reviews.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
stars: 1
|
||||
comment: MyText
|
||||
movie: one
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
stars: 1
|
||||
comment: MyText
|
||||
movie: two
|
7
test/models/review_test.rb
Normal file
7
test/models/review_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class ReviewTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user