Skip to content

Instantly share code, notes, and snippets.

@joncode
Created October 10, 2014 18:25
Show Gist options
  • Save joncode/6f7be4ab8d19a1e994f1 to your computer and use it in GitHub Desktop.
Save joncode/6f7be4ab8d19a1e994f1 to your computer and use it in GitHub Desktop.
Useful Rails API methods

ApplicationController.included_modules

ApplicationController.ancestors - ApplicationController.included_modules

HelpsController.action(:index) #=> returns a proc rack application - plus the line of the source code metal.rb:230 #Proc:0x007fcfad287a38@/Users/jongutwillig/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.0/lib/action_controller/metal.rb:230 HelpsController.method(:action).source_location #=> where it is defined ["/Users/jongutwillig/.rvm/gems/ruby-2.1.1@global/gems/actionpack-4.1.0/lib/action_controller/metal.rb", 229]

There are TWO MIDDLEWARE STACKS ! - one for the app - one for controller lookup

in a controller use Rack::ShowExceptions, only: :show #=> uses the rack show exceptions middleware instead of Rails exceptions

rake middleware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment