On 19 May 2014 05:18, Christophe N. <li...@ruby-forum.com> wrote: > I'm not sure what is the best approach for my problem. I need a model > for notification (or alerts) in my application. Notifications are based > on > services, have multiple fields to define conditions and are associated > with a user. Here's an example for a reddit notification: > > user_id: 1 > type: post_karma > condition: above > value: 100 > > And here's a weather notification: > > user_id: 2 > type: temperature > city: Seattle > condition: above > value: 70 > > So both entries are notifications but they have different fields. Should > I: > > - Create different models for each type of notification? > - Create a base notification model and other models for each type that > extend the base one? > - Only have 1 model (notification) and then some sort of condition > table. A notification has multiple conditions.
Have you considered STI? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsBiuaW%3DXbjiYiUF7zreBdr8BtegyLuxmXf3E5RvnbWBg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.