aguynamedloren
aguynamedloren

Reputation: 2273

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/etc. I can think of a number of hacky ways to accomplish this, but none of them seem elegant and robust.

Any ideas?

Upvotes: 0

Views: 635

Answers (2)

HChen
HChen

Reputation: 2141

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.

Upvotes: 0

Nick Hammond
Nick Hammond

Reputation: 11419

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.

Upvotes: 1

Related Questions