Monday, 9 September 2013

Rails - mixin module - check if base responds to a method

Rails - mixin module - check if base responds to a method

I have created a module in order to implement a common controller action:
order
When I define the method I want to check if the controller that has
included the module, responds to a specific method (authorize_respond).
How can I achieve that?
Find below my current implementation that doesn't work (never calls the
method authorize_ordering).
def order
send(:authorize_ordering) if self.respond_to?(:authorize_ordering)
ordering = params[:ordering]
...
end

No comments:

Post a Comment