parent
38e5234b64
commit
5a1ee09fd3
@ -0,0 +1,2 @@
|
||||
class GenresController < ApplicationController
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module GenresHelper
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
class Characterization < ApplicationRecord
|
||||
belongs_to :movie
|
||||
belongs_to :genre
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class Genre < ApplicationRecord
|
||||
validates :name, presence: true, uniqueness: true
|
||||
|
||||
has_many :characterizations, dependent: :destroy
|
||||
has_many :movies, through: :characterizations
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
class CreateGenres < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :genres do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
class CreateCharacterizations < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :characterizations do |t|
|
||||
t.references :movie, null: false, foreign_key: true
|
||||
t.references :genre, null: false, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class GenresControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
movie: one
|
||||
genre: one
|
||||
|
||||
two:
|
||||
movie: two
|
||||
genre: two
|
@ -0,0 +1,7 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
|
||||
two:
|
||||
name: MyString
|
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class CharacterizationTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class GenreTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in new issue