Posted about 1 month ago. Visible to the public.

Rails: Invoking a view helper from the console

There are a few ways to access view helpers from the Rails console. The easiest way is the helper shortcut:

Copy
helper.translate 'i18n.string' helper.your_helper_method

If the desired helper renders a view template, you need this setup:

Copy
view_paths = Rails::Application::Configuration.new(Rails.root).paths["app/views"] av_helper = ActionView::Base.new(view_paths).extend YourHelperModule av_helper.your_helper_method

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Dominik Schöler
Last edit:
about 1 month ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more