New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActionController filter initialization #4219
Comments
Hey @pmeinhardt have you got any solution for this?? Or this problem still exists for you? |
Hey, I haven't had the time to dig into it since then. However, if you have any clue on how to solve this, I'd appreciate any hints. It's strange I have to call the Another solution that I considered in the meantime was using cuts to hook into arbitrary methods outside the regular Rails This (instrumenting methods) should be a common problem in web applications/analytics so if anyone can point me to sth. better, I'd be more than grateful. |
Hey @pmeinhardt, I think I may not be understanding quite right what you're trying to achieve here. By giving a symbol to So, if I got your idea right, it'd look something like this: module Tracking
module ControllerAdditions
def track(*actions)
before_filter only: actions do |con|
puts "Tracking [#{con.action_name}]: #{con.class} #{con}"
end
end
end
def self.included(base)
base.extend ControllerAdditions
end
end
# controller
class PostsController < ApplicationController
include Tracking
track :index
def index
@posts = Post.all
end
end
# logger output
# Tracking [index]: PostsController #<PostsController:0x007fa064161ac8> This was tested with a newly generated app and Rails 3.2.3. If that's not the path you're trying to go here, please try to explain a little bit better so we can verify it that's a real issue. Thanks. ps: about your question related to instrumentation, the best thing for it nowadays I believe would be AS::Notifications. |
Argh. Yes @carlosantoniodasilva, you're absolutely right. I completely used the Thanks also for the hint about AS::Notifications, I'll dig right into it. Cheers, |
Ok, great, thanks :). AS::Notifications it totally worth a try. Cheers. |
Hi, I encountered this strange behaviour, when trying to set up a controller *_filter from an incuded module:
The module code looks similar to this (shortened it for readability)
It is then included in a controller as follows:
Problem is, that
I use Rails 3.1.3.
Thanks for your help.
Regards,
Paul
The text was updated successfully, but these errors were encountered: