RailsCasts Pro episodes are now free!
Learn more or hide this
Can i use this, for clear cache?
Yes. I think the convention is to use sweepers/observers though. Assuming you want it async that is, otherwise just call your cache clear method directly and make it more obvious what you're trying to do.
Cool! Many many thanks.
Do you think that notifications could be suitable for pub/sub like jcoglan faye for nodejs and rack does?
Thanks for the screencast, Ryan.
Holding this logic in an initializer seems odd. I'm going to assume you could place that block almost anywhere else.
I have seen a presentation on Domain Driven Design with Rails by Pat Maddox where he plays around with the notion of generating and consuming events as a means to decouple concerns. Makes me wonder if you might do it with these. I know you advise against this, but am wondering how that would feel.
Of course, with the above, you have to consider how it would be tested.
I am also interested in your opinion on a suitable mechanism to implement a model focused pub/sub system for simple events.
I am currently using Observers and custom events (ActiveModel::Observing#notify_observers) but the simplicity of this approach and the RegExp matching capability seems to be a better approach to me.
Since I am only interested in my custom events the Observers are pretty much overkill and the presented method would work quite well. Do you see any other major drawbacks than scattering the code (because I need to extract some core business logic into external places)
Hey Ryan do you believe that the Notifications is a good place to catch exception or Rack is better? Ideally I would to track all exceptions not just the ones that happen during a request for example catch exception when using Runner or when an asyncronous function is executed in a task queue.
Very nice, so it's a bit like objective-c/cocoa does it.
How you unsubscribe of one Notification? I have a very annoying Notification and I really want to remove it, I've try with
$> ActiveSupport::Notifications.unsubscribe( ActiveSupport::LogSubscriber.flushable_loggers.first )
but nothing of this works.
The notifications seem to be of active_record, here is one of the infinity notification that I see
Got notification: #<ActiveSupport::Notifications::Event:0xba9bdd8 @name="sql.active_record ......
I don't know how the notification were activated but I can't disable them, please help
How can I render page_duration time in my layout?
See http://blog.locomotivellc.com/post/4544746167/query-trace for an ActiveRecord subscriber that shows where a query is called from.
it's interesting to hear you say why you suggest not using notifications for app logic. the reasons you listed for not using it are the exact reasons that i want to use it for my app logic. :)
i've got a blog post from yesterday that talks about the scenario that I'm trying to solve and how I would have used the event aggregator pattern if i were building a .net / winforms application. the notifications system is an event aggregator built right into rails, and is perfect for what I need.
if you're interested, here's that blog post: How do you handle simple pub-sub, evented architecture in rails apps?
This speakerdeck presentation by Matt Sanders dives even deeper into ActiveSupport::Notifications, and is an excellent companion to this Railscast.
I have a problem with rails notifications described here
Doesn't work if I use respond_with (db_runtime is always 0 after POST request)
How to Care for Coach Leather Handbags www.mkpee.com
Coach leather handbags are very desirable and fashionable. Coach is known for its high-quality goods and its styles have passed the test of time. www.mkuker.com Women proudly carry their Coach leather handbags for many years. They are, however, a major investment. www.mkzho.com Once you have purchased one, you will want to keep it in excellent www.nikeyeah.com condition to protect that investment. www.mkpee.com Be aware of where you are putting your bag; try not to place it on the floor. A purse hook is a handy little item to carry in your purse that lets you www.nikeshoesales.com hook your purse to a tabletop or other flat surface.
Lightly www.lightupshoe.sale clean your purse once a month, or more often if you carry it in a dirty environment. You can use a baby wipe to lightly wipe the surface. There are also leather wipes available. You do not want to get your Coach leather handbag wet so do not use a wet cloth to clean it. Use Coach-brand fabric cleaner if your bag is a signature Coach bag made of fabric. The fabric cleaner should only be used on fabric bags. www.nikemax.shoes Use a high-quality leather cleaner for heavier cleaning. www.shoesmaxs.com
After cleaning your handbag, apply a high-quality leather moisturizer to help keep it conditioned.To clean the inside of your bag, use the hose attachment on your vacuum and gently clean the inside.After cleaning, always store your handbag in the www.mkfact.com dust bag that came with it or a cotton pillow case. Lay it flat on a shelf and do not stack or crush your Coach leather handbags.
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working paper writing service review
style so speedy. I think it may be help all of you. Thanks a lot for enjoying this beauty blog with me. I am appreciating it very much! Looking forward to another great blog. Good luck to the author! all the best!
It is just what I was looking for and quite thorough as well. Thanks for posting this, I saw a couple other similar posts but yours was the best so far. The ideas are strongly pointed out and clearly emphasized.
First sign in through GitHub to post a comment.