Last Updated: February 25, 2016
·
2.385K
· rbgrouleff

Accessing view helpers in a rails runner session

If you ever need access to view helpers during a rails runner session like in the rails console, this will give it to you:

helper = ApplicationController.helpers

If you need Url helpers too (both in rails runner and console), just do this:

helper.class_eval { include Rails.application.routes.url_helpers }

1 Response
Add your response

Thanks for the tip! I used this to find out where I screwed up my devise routes when upgrading from Rails 2 to Rails 3.

git bisect start; git bisect good GOOD_REF; git bisect bad BAD_REF; git bisect run bundle exec rails runner 'Rails.application.routes.url_helpers.new_user_session_path'

over 1 year ago ·