Rails: how to write a better association condition? -
in rails 2.3.8 have 2 models news , user.
in app i'd able show each registered user news has not still read. in homepage each piece of news should presented in box , user should able click on "x" , hide news forever (just profile).
one way have user_news model and, each time piece of news created generate record in user_news model each user , update linking record each user "read" field set true. create association in user model like:
class user < activerecord::base has_many :unread_news, :through => :user_news, :source => :news, :conditions => 'read not true'
the problem approach if have thousands of users in app, each time publish piece of news need create thousands of records in user_news table.
my question is: possible write association between user , news model tells rails like:
"unread news each user every existing news except ones appear in user_news table"?
anyway how approach goal?
thanks, augusto
seems talking nosql solution. if sure it, try mongodb
Comments
Post a Comment