# Link\_to\_remote : render a view

**URL:** <https://www.ruby-forum.com/t/link-to-remote-render-a-view/161890>\
**Category:** Rails\
**Created:** [March 3, 2009, 1:29pm UTC](https://www.ruby-forum.com/t/link-to-remote-render-a-view/161890 "2009-03-03T13:29:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [March 3, 2009, 1:29pm UTC](https://www.ruby-forum.com/t/link-to-remote-render-a-view/161890/1 "2009-03-03T13:29:36Z")

</div>

when a user clicks on a link\_to\_remote I would like to it to render a  
view that i already have established. I know about page.redirect\_to but  
that would force a refresh. Id like to do something like page.replace  
“an\_existing\_view”  
is this possible or would i have to convert the view into a partial  
first?

---

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [March 3, 2009, 2:03pm UTC](https://www.ruby-forum.com/t/link-to-remote-render-a-view/161890/2 "2009-03-03T14:03:21Z")

</div>

On 3 Mar 2009, at 12:29, Adam A. wrote:

> when a user clicks on a link\_to\_remote I would like to it to render a  
> view that i already have established. I know about page.redirect\_to  
> but  
> that would force a refresh. Id like to do something like page.replace  
> “an\_existing\_view”  
> is this possible or would i have to convert the view into a partial  
> first?

You can replace any element on the page (so I suppose you could do an  
update on the body element, although I’ve never done that.  
It is most common to have a partial for exactly that bit of the page  
that needs refreshing (if you’re using ajax to refresh the entire page  
then it seems to me like you might as well keep it simple and just do  
a non ajax update) but you shouldn’t have to do that.

Fred

---

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [March 3, 2009, 2:26pm UTC](https://www.ruby-forum.com/t/link-to-remote-render-a-view/161890/3 "2009-03-03T14:26:50Z")

</div>

thanks fred, what im doing is pertty much like gmail. I have links on my  
side nav equivalent to gmails “inbox” and “starred”. When i click on  
inbox in gmail it renders the list of emails in my inbox without a  
refresh. Teh same with all “starred” etc. Id like that functionality.

So i guess id have to extract that area of the screen into a partial and  
call it via a page.replace\_html “the\_partial” and for standard html  
responses just render the same partial in the actions view? right???

---

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [March 3, 2009, 2:51pm UTC](https://www.ruby-forum.com/t/link-to-remote-render-a-view/161890/4 "2009-03-03T14:51:09Z")

</div>

On 3 Mar 2009, at 13:26, Adam A. wrote:

> responses just render the same partial in the actions view? right???  
> Yes. If you’re just updating that one page element you don’t even need  
> replace\_html, just do

link\_to\_remote ‘blah’, :update =\> ‘some\_id’, …

and have the corresponding controller render some (html) partial in  
the normal way, the results of the render will be used to update the  
page element with that id

Fred
