0
class Card < ApplicationRecord
has_one :card_rating
has_one :rating, through: :card_rating
end
class Rating < ApplicationRecord
has_many :card_ratings
has_many :cards, through: :card_ratings
end
class CardRating < ApplicationRecord
belongs_to :card
belongs_to :rating
end
ich etwas entlang der Linien der folgenden Aktionen ausführen möchten:Wie ein Objekt erstellen - hat man: durch
c = card.card_rating.new
c << rating
Aber es scheint nicht zu sein, jede Vereinigung geht überhaupt, da bereits bei der ersten Anweisung die folgende Fehlermeldung erhalte ich:
undefined method `new' for nil:NilClass