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 web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
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)