Ruby on Rails
Monday, October 21, 2019
On Monday, October 21, 2019 at 7:31:36 AM UTC-4, Ariel Juodziukynas wrote:
ItemItemProperty is wrong, belongs_to association should be singular not plural: belongs_to :item and belongs_to :item_propertyEl lun., 21 oct. 2019 08:27, fugee ohu <fuge...@gmail.com> escribió:--i=Item.firsti.item_propertiesNameError: uninitialized constant Item::ItemPropertiesclass Item < ApplicationRecord
has_many :boxes
has_many :item_pictures
has_many :pictures, through: :item_pictures
has_many :item_item_properties, primary_key: 'item_type', foreign_key: 'item_type'
has_many :item_properties, through: :item_item_properties
ITEM_TYPES = ['General', 'Book', 'Record', 'Magazine', 'Pez dispenser', 'CD', 'VHS casette']
validates :item_type, inclusion: ITEM_TYPES
attr_accessor "Year"
endclass ItemItemProperty < ApplicationRecord
belongs_to :items, primary_key: 'item_type', foreign_key: 'item_type'
belongs_to :item_properties, primary_key: 'item_type', foreign_key: 'item_type'
endclass ItemProperty < ApplicationRecord
has_many :item_item_properties, primary_key: 'item_type', foreign_key: 'item_type'
has_many :items, through: :item_item_properties
end
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonra...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .065ff213-21fe-4b69-a41c- 7966bd82a12c%40googlegroups. com
Could not find the source association(s) "item_property" or :item_properties in model ItemItemProperty. Try 'has_many :item_properties, :through => :item_item_properties, :source => <name>'. Is it one of item or item_propertie?
Is rails as confused as I am? Why does it have "propertie" in the error?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/20fcab20-2009-4a44-9485-14e41ae09a33%40googlegroups.com.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment