Search code examples
ruby-on-railsrubyruby-on-rails-3mixins

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

Solution

  • Embarrassing, never mind.

    Method authorize_ordering was protected. Being public works as expected.