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 }
Written by Rasmus Bang Grouleff
Related protips
1 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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#