As a noob in rails, i am having a problem on how to find a decent and straightforward notifications system for my application.
Being a Api like application (talking with the client is made using JSON / later on XML as well), i have a problem finding a good solution to feed my needs.

I have tried to use the rails validators, but then i have realized that is not a good solution, as i need to send normal notifications as well (Ex: "You have successfully bought this item" ).

After that ideea failed ... I have tried to implement a "Notification" module inside my user model as, all my notifications are user related. However ... this system has 2 instance variables : @notifications and @api_errors. Now, the problem would be the validation of the user action, and here might be several messages to send:

- Stock finished
- No money
- No access to this feature ...
- CC invalid
... etc

now ... i can do my checks like

if false == money_requirement?
self.add_api_error "You do not have enough money"

if false == product.stock_requirement?
self.add_api_error ....

But the main problem ... would be now, the method of trigger the action.

if self.api_errors.size == 0
# do play with the user account, stocks and other stuff ....

what i am asking you: Is there any way to play with those notifications and errors without passing through the database? They are more like flashes, but the code is inside the model ... so, i don't want to fall into an antipattern having session related info inside my model.


You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
grouprubyonrails-talk @
postedMar 11, '12 at 9:14a
activeMar 21, '12 at 2:44p



site design / logo © 2022 Grokbase