开发者

Ruby on Rails: Notification System For Different Sets of Tags

I have a site with a tagging system but would like to enable users to be able to subscribe to different sets of tags of their choice so that w开发者_开发技巧hen a new submission is made and has tags that match what the user is subscribed to they get a notification. For example, say a user is only interested in red, wallpapers that are considered large. They would add those three tags to a set and when a wallpaper is added that contains those tags the user gets a notification. They would need to be able to do this with any set of tags. It seems like a tricky problem, and I can't seem to come up with a simple solution. Does anyone know if this is already solved in a Gem somewhere, or have any ideas on how to do it efficiently?

Thanks for looking


You can make User model taggable also:

# User model
acts_as_taggable

And add user selected tags to their User object: @user.tag ['wallpapers', 'red', 'large'] And then in model for which you want notifications add:

after_create :send_notifications

def send_notifications
  @users = User.find_tagged_with :all => self.tag_names
  @users.each do |u|
    something_that_will_send_notification_to_user u
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜