On Friday, February 2, 2018 at 5:01:05 PM UTC-5, Colin Law wrote:
>
> On 2 February 2018 at 19:39, fugee ohu <fuge...@gmail.com <javascript:>> 
> wrote:
>
>>
>> So if I'm using the second approach the has_many_through then how do i 
>> create a new record? 
>>
>
> Start by reading the rails guide on active record relations, that shows 
> you how to do that sort of thing.
>
> Colin
>  
>


This code `@person.pictures << @picture` causes an error

Could not find the association :people_pictures in model Person

class PeoplePictures < ApplicationRecord
 belongs_to :person
 belongs_to :picture

class Person < ApplicationRecord
 has_many :pictures, through: :people_pictures

class Picture < ApplicationRecord
  has_many :people, through: :people_pictures

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/81d55ecb-6bda-41b1-a2c5-2d5f868affed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to