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_property
>
> El lun., 21 oct. 2019 08:27, fugee ohu <[email protected] <javascript:>> 
> escribió:
>
>> i=Item.first
>> i.item_properties
>> NameError: uninitialized constant Item::ItemProperties
>>
>> class 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"
>>  
>> end
>>
>> class 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'
>> end
>>
>> class 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/065ff213-21fe-4b69-a41c-7966bd82a12c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rubyonrails-talk/065ff213-21fe-4b69-a41c-7966bd82a12c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
 In form_for(item) how do i create a text_field for item.item_property.name 
where item  has_many :item_properties, through: :item_item_properties, 
primary_key: 'item_type', foreign_key: 'item_type'

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/cf4f7fbb-a29f-4d4f-a1ea-83499e09b9cb%40googlegroups.com.

Reply via email to