* added podcast_ownership route * added podcast_ownership table * added podcast_ownership controller and pundit policy * fixed codeclimate * removed controller and pundit policy * codeclimate * codeclimate * schema.rb * schema.rb * schema.rb * user.rb * made the suggested changes * added validations * fixed build error * changed name to owned_podcasts * added validation and tests * added tests * added tests * changed spec * added factory * added factory * merge conflict * factory * factory * factory * modified spec file * modified spec file * fix build error * added class_name * adjusted m2m relations * made suggested changes * fixed build error * added subject * schema * ran migration * removed index:true from singular fields * changed schema file * set index: false
7 lines
269 B
Ruby
7 lines
269 B
Ruby
class PodcastOwnership < ApplicationRecord
|
|
belongs_to :owner, class_name: "User", foreign_key: :user_id, inverse_of: :podcasts_owned
|
|
belongs_to :podcast
|
|
|
|
validates :podcast_id, uniqueness: { scope: :user_id }
|
|
validates :podcast_id, :user_id, presence: true
|
|
end
|