DB fields not showing up in association custom queries?

Posted by Kevin on Stack Overflow See other posts from Stack Overflow or by Kevin
Published on 2010-05-31T08:57:48Z Indexed on 2010/05/31 9:03 UTC
Read the original article Hit count: 153

Filed under:
|

I have a notification list that the user can select different show options for different kinds of notifications along with how many results are returned. I'm keeping them in the user model because I want the custom sort to stay with the user between sessions. Here is the association in my user model:

has_many :notifications,
       :class_name => "Notification",
       :foreign_key => "user_id",
       :conditions => ["won = ? and lost = ? and paid = ?", self.prefs_won, self.prefs_lost, self.prefs_paid],
       :limit => self.prefs_results.to_s

But when I use the above code, Rails throws me an "unknown method" error for self.prefs_won. It is definitely a field in my database and set as a boolean value, but Rails can't find it... what's the problem?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about beginner