开发者

Display notification messages to users at specific intervals (Ruby on Rails)

I am working on an application with basic authentication functionality. When a user registers, I would like to display a javascript lightbox message containing a brief introduction to the application. Additionally, I would like to display notifications when a user logs in after a set time span (1 week, 1 month, etc). I'm not sure flash notifications will suffice as I plan on having slightly complex html in the messages, with forms/links/et开发者_如何学JAVAc. I can think of a number of hacky ways to accomplish this, but none of them seem elegant and robust.

Any ideas?


You can just keep track of the login count and when it's their first login just activate the lightbox.

if current_user.sign_in_acount == 1
  # render welcome lightbox
end

if current_user.created_at > 1.week.ago && not_notified?
  # render notification lightbox
end

There won't really be an out of the box solution or anything and since you have two different types of scenarios for messages(time vs. login count) it's something you can just do for the small amount of times you are going to have to do it.


Maybe append a special parameter at the end of the URL after the user registers, and have JavaScript check for it? So after registration, send user to /whatever_page?just_registered, and have some JS code to check that.

if(window.location.search.test(/just_registered/)){
  // pop up lightbox
}

Or you can just do a temporary cookie, set it, let Javascript check it, show the lightbox and delete it right away. You can do something similar with the display notification thing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜