I implemented an achievements system in my application. Everything works perfectly. I would like to add a feature that creates a pop up (modal dialog box, I am using jquery) when my achievement is triggered. So, I don't really know how do I handle the dialog creation, logically I should put in my observer method (right?), but I don't really know how to start. I would like to have some pointers.
Thank you.
class MyFirstCarObserver < ActiveRecord::Observer
observe :user_car
def after_save(user_car)
MyFirstCar.award_achievements_for(user_car.user)
# Need to create a dialog box
end
end
I have similar code where I set a session variable (session[:alert]) and then later in my application layout file I have a line that puts the content of session[:alert], if there is any, into a Javascript dialog box. This kind of code should be in the controller however.