> ## Content Index
> Fetch the complete content index at: https://til.codes/llms.txt
> Use this file to discover other available public pages before exploring further.

# Calling View helper methods from Controller / Model in Rails
- URL: https://til.codes/calling-view-helper-methods-from-controller-model-in-rails/
- Published: 2015-07-17T11:55:20.000Z
- Updated: 2015-07-17T11:55:20.000Z
- Author: Manu Ajith
- Tags: ruby, rails, helpers, #Import 2024-07-13 21:01

Recently I was researching a way to use `link_to` inside my Rails 3 controller, and learned about the method `view_context`.

So if you ever want to access view helper methods from controller / models in rails 3 you have to use view\_context method.

Example

```
view_context.link_to 'Link', link_path(@link)}.

```

PS:

Just a note that you should avoid calling these functions within the controllers to follow mvc pattern conventions.