- I have a notifications table which contains different types of notifications for different events.
- Inside the table is a
notifications_type:stringcolumn that contains the type of notification, i.e. “foo” or “bar” or “oof” - I want the user to be able to select what notifications they want to display, so there are checkboxes below the result that correspond to
prefs_display_foo:boolean, prefs_display_bar:booleanin the User model. - What is an elegant way for me to set the
:conditionsin the find to properly display the sorted results? Also, currently I have it as a method in the User model, but how would I do it as ahas_many :notifications, :conditions => .....
I have a notifications table which contains different types of notifications for different events.
Share
You could try this
leave the has_many without any conditions and then create a named_scope to handle the preferences, this code is untested