How to assemble through several subcategories

How do rails see messages nested under several associative models that have a user interface?

    @user = current_user
    @user_clubs = @user.clubs   #user is a member of many clubs (habtm), clubs have many events to post a quantity of products to
    @uc_products = @user_clubs.collect {|a| a.products}  # clubs have many products (and categories, haven't implemented yet) (with title, description, etc)
   # @ucp_posts = @uc_categories.collect {|a| a.posts}   # products have many posts (product_id, quantity, & date offered only)

the registrar gives me collections, so I know that the code works up to this point

#<User:0x58d4300>
#<Club:0x5aa82e8>#<Club:0x5aa3578>
#<Product:0x59150e8>#<Product:0x5911bc0>#<Product:0x58582b0>

I can collect products, but as soon as I try to collect messages from this, it gives me an error

undefined method `posts' for #<Class:0x5a248d0>

I tried: enable, both directions, to no avail.
Edit: here are most of my models: (I thought this could crowd things up before, didn't include)

        class Post < ActiveRecord::Base
          belongs_to :product, :include => :club
          belongs_to :event

    class Product < ActiveRecord::Base
        belongs_to :user
        belongs_to :club
        belongs_to :category
        has_many :posts

    class Club < ActiveRecord::Base
        has_many :products, :include => :posts
            has_many :events
            belongs_to :users_clubs
            has_many :users_clubs
            has_many :users, :through => :users_clubs, :foreign_key => :users_club_id

class UsersClub < ActiveRecord::Base  #table for joining habtm
    has_many :users
    has_many :clubs
    belongs_to :user
    belongs_to :club

class Event < ActiveRecord::Base
    has_many :posts
    belongs_to :club


    class User < ActiveRecord::Base
      # Include default devise modules. Others available are:
      # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
      devise :database_authenticatable, :registerable,
             :recoverable, :rememberable, :trackable, :validatable

      # Setup accessible (or protected) attributes for your model
      attr_accessible :name, :email, :password, :password_confirmation, :remember_me,
                      :bio, :reason, :barter

                      #:email, :name, :bio, :reason, :barter, :

      belongs_to :roles_users                
      has_many :roles_users
      has_many :roles, :through => :roles_users

      belongs_to :users_clubs                
      has_many :users_clubs
      has_many :clubs, :through => :users_clubs, :foreign_key => :users_club_id

      has_many :approvals, :dependent => :destroy
      has_many :products, :dependent => :destroy
      has_many :posts, :dependent => :destroy
      has_many :orders, :dependent => :destroy

:
, , . http://guides.rubyonrails.org/association_basics.html, , . , "" "" . " ", 4 , . , , .

? , Google? noob.

2
- ,
Rails ( )
? ( )

0
2

..

http://rubygems.org/gems/nested_has_many_through, - :

class Author < User
  has_many :posts
  has_many :categories, :through => :posts, :uniq => true
  has_many :similar_posts, :through => :categories, :source => :posts
  has_many :similar_authors, :through => :similar_posts, :source => :author, :uniq => true
  has_many :posts_of_similar_authors, :through => :similar_authors, :source => :posts, :uniq => true
  has_many :commenters, :through => :posts, :uniq => true
end

class Post < ActiveRecord::Base
  belongs_to :author
  belongs_to :category
  has_many :comments
  has_many :commenters, :through => :comments, :source => :user, :uniq => true
end

.

0

, has_many Product, ?

:

class Product < ActiveRecord::Base
  has_many :posts
end
0

All Articles