Thursday, November 21, 2013

[Rails] ApplicationController class method not being called each page load

Ruby 2, Rails 4, bundler

I'm trying to package a bunch of my own reusable libs into gems. I did
this quite some time ago for Ruby 1.8, Rails 3. Now I'm updating
everything, and trying a new approach to the gem structure as well.
Something is hinky, and I've run out of ideas to figure it out.

At this point I have a fresh Rails 4 project, and working on my
first gem--it's a logger which I have used for eons.

In ApplicationController I have:

class ApplicationController < ActionController::Base
global_logger :chatty
end

The problem I am seeing is that global_logger is being run only one
time. In all my previous versions (as a Rails 2 plugin, and a Rails 3
gem) that class method runs from scratch every page load and I count on
that behavior to do some things. In this new Rails 4 setup, it is
running the first time and that's it. The rest of my logger code
(writing messages from subsequent controllers) seems to work fine.

Is there some new thing to Ruby 2 / Rails 4 I've not read about?

Anyway, before I spew 4 pages of code details, my first question is
whether or not the running-once behavior is something new which is
expected (doesn't make sense to me but who knows).

If not, then I can provide some details of how I've structure the gem,
and the class methdods.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6c4e6661d23afea94ec3b564d04137c0%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate