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