On Saturday, February 3, 2018 at 5:49:13 PM UTC-5, Walter Lee Davis wrote:
> > On Feb 3, 2018, at 3:56 PM, fugee ohu <fuge...@gmail.com <javascript:>> 
> wrote: 
> > 
> > 
> > 
> > On Friday, January 12, 2018 at 7:06:12 PM UTC-5, fugee ohu wrote: 
> > Let's say I have a table of products and a table of accessories Each 
> accessory can have many products that it's compatible with while each 
> product has many accessories available for it It In the problem I'm trying 
> to solve accessories cannot belong to products and products cannot belong 
> to accessories So, unless I was to create a third table with fields for 
> product_id and accessory_id, how could I allow each to have many of the 
> other Do I have to create the third table? Thanks in advance 
> > 
> > @person.pictures << @picture tries to, create a new picture, not add it 
> to the person_picture association table 
> Where does @picture come from? Did you build it in memory, or load it from 
> the database? Rather than adding an object you created to an association, 
> try building the associated object from the beginning, like this: 
> @picture = @person.pictures.build(picture_attributes) 
> Now that picture is automatically in the @person.pictures association, and 
> has whatever other attributes you assigned to it. 
> When you save the picture, the corresponding person_picture instance will 
> be persisted as well. The picture has to be created and saved before the 
> person_picture record can be, otherwise where would the 
> person_picture.picture_id value come from? 
> Walter

to do that i added accepts_nested_attributes_for :picture it didn't create 
the  association

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 
For more options, visit https://groups.google.com/d/optout.

Reply via email to