How do rails see messages nested under several associative models that have a user interface?
@user = current_user
@user_clubs = @user.clubs
@uc_products = @user_clubs.collect {|a| a.products}
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
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
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :name, :email, :password, :password_confirmation, :remember_me,
: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 ( )
? ( )