# Views & link\_to

**URL:** <https://www.ruby-forum.com/t/views-link-to/121806>\
**Category:** Rails\
**Created:** [December 1, 2007, 3:04am UTC](https://www.ruby-forum.com/t/views-link-to/121806 "2007-12-01T03:04:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f05b48/32.png) [@danb](https://www.ruby-forum.com/u/danb)\
**Post date:** [December 1, 2007, 3:04am UTC](https://www.ruby-forum.com/t/views-link-to/121806/1 "2007-12-01T03:04:44Z")

</div>

I have a few related questions about views. Specifically,  
how do you call link\_to from a method rather than a view?  
Calling from a method in the model,  
the result of  
ActionView::Helpers::UrlHelper.link\_to(…)  
is  
undefined method `link\_to’ for ActionView::Helpers::UrlHelper:Module

More generally, how does Rails process a view? What is self inside an  
ERb form?  
What is its class? (self.class called inside the view returns “#”)  
How does it get instance variables from the controller? How does it  
get access to link\_to?

---

<div class="post-metadata">

**Author:** ![danb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f05b48/32.png) [@danb](https://www.ruby-forum.com/u/danb)\
**Post date:** [December 1, 2007, 6:59am UTC](https://www.ruby-forum.com/t/views-link-to/121806/2 "2007-12-01T06:59:41Z")

</div>

On Nov 30, 8:04 pm, danb [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> how do you call link\_to from a method rather than a view?

Okay, I finally learned what a module instance method is.  
But link\_to calls url\_for, which looks for @controller, which  
is an attribute of ActionView::Base. So what does the object  
need to inherit from, and how do you instantiate it?
