This is a example. I solve it. Thank you.

On Sep 15, 9:25 pm, Frederick Cheung <[email protected]>
wrote:
> On Sep 15, 12:22 pm, Doloo <[email protected]> wrote:
>
> > So when i trying add new product. I get errors.
> > # products_controller.rb
> >   def new
> >     @product = current_user.product_groups.products.build
> >   end
> > The error I'm receiving is:
>
> >    NoMethodError (undefined method `products' for #<Class:0x2ca50b0>):
> >      app/controllers/products_controller.rb:27:in `new'
> >      -e:2:in `load'
> >      -e:2
>
> A collection of product_groups doesn't have a products method
> (individual product group do).
> Users have a products association, so why not do
> current_user.products.build ? (Although I'm not sure if you can do a
> has_many through where the join model has a has_many)
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to