I am writing an application in which the user can create their own pages for people to post messages, and follow the messages on the pages created by users. Here's what my model relationship looks like at the moment ...
class User < ActiveRecord::Base has_many :pages has_many :posts has_many :followings has_many :pages, :through => :followings, :source => :user class Page < ActiveRecord::Base has_many :posts belongs_to :user has_many :followings has_many :users, :through => :followings class Following < ActiveRecord::Base belongs_to :user belongs_to :page class Post < ActiveRecord::Base belongs_to :page belongs_to :user
The problem arises when I try to make my way through relationships to create the homepage of the pages (and corresponding messages) that the given user sets (similar to how the Twitter homepage works when you log in - a page that provides you with a consolidated view of all the latest posts from the pages you follow) ...
I get a "method not found" error when I try to call followings.pages. Ideally, I would like to be able to call User.pages so that it gets the pages that the user is following, and not the pages that they created.
I am programming and Rails newb, so any help would be greatly appreciated! I tried to find as much of this site as possible before posting this question (along with numerous Google searches), but nothing seemed specific as my problem ...
source share