Read more

Rails: Accessing helper methods from a controller

Henning Koch
February 15, 2023Software engineer at makandra GmbH

In Rails 5+ you can access a helper from a controller using the helpers method:

# Inside a controller action
helpers.link_to 'Foo', foo_path
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

In older Rails versions you can use view_context instead:

# Inside a controller action
view_context.link_to 'Foo', foo_path
Posted by Henning Koch to makandra dev (2023-02-15 10:21)