Hi,
I''m trying to write a plugin that should inject an action into the
controller.
Please note, not just an instance method, but also an _action_, one of those
that are listable by running ControllerClassName.action_methods.
I wrote the following code:
def render_field_search(name, object, controller, options = {})
controller.class.class_eval do
define_method("#{name}_flt") {
raise ''Here iam!''
}
end
# this should define the new method as an action too
controller.class.action_methods << "#{name}_flt"
[..]
end
It works if I try to call the method from inside render_field_search() itself,
it fails if I call it as normal HTTP request:
ActionController::UnknownAction
(No action responded to reservation_customer_id_flt):
/actionpack-1.12.3/lib/action_controller/filters.rb:368:
in `perform_action_without_benchmark''
Does anyone know why this happens?
Thanks.
Cheers,
Marco
Keywords for future searches:
inject action method controller plugin class_eval eval