Rails: Как получить доступ к текущему контроллеру в Observer?

Мне нужно получить доступ к текущему контроллеру или высветить уведомление от метода наблюдателя.

class SomeObserver < ActiveRecord::Observer
    observe :some_model
    cattr_accessor :current_controller

    def after_create(record)
        ...
        current_controller.flash[:notice] = "Some message!"
    end
end

class ApplicationController < ActionController::Base
    before_filter do
        SomeObserver.current_controller = self
    end
    ...
end
5
задан Andrey Dhzukov 15 November 2011 в 18:49
поделиться