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 money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
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)