# Why render doesn't work

**URL:** <https://www.ruby-forum.com/t/why-render-doesnt-work/157020>\
**Category:** Rails\
**Created:** [January 6, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/why-render-doesnt-work/157020 "2009-01-06T15:07:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/why-render-doesnt-work/157020/1 "2009-01-06T15:07:39Z")

</div>

I use render in a view page like this:

\<% form\_for :project do |form| %\>

 \<%= render :partial=\>'project\_version' %\> 

| \<%= select\_tag:project\_selection,options\_for\_select(@project\_names) %\> \<%= observe\_field :project\_selection, :frequency =\> 0.5, :update =\> 'project\_version\_ajax', :url =\> {:action =\> 'update\_project\_selection'} %\> |

\<% end %\>

In update\_project\_selection controller:

def update\_project\_selection  
…  
render :partial=\>‘project\_version’  
end

when the select box changed its value, the controller is invoked but the  
\_project\_version.html.erb doesn’t update.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 3:28pm UTC](https://www.ruby-forum.com/t/why-render-doesnt-work/157020/2 "2009-01-06T15:28:54Z")

</div>

On 6 Jan 2009, at 14:07, Zhao Yi wrote:

> \<%=  
> observe\_field :project\_selection,  
> :frequency =\> 0.5,  
> :update =\> ‘project\_version\_ajax’,  
> :url =\> {:action =\> ‘update\_project\_selection’} %\>
> 
> \<%= render :partial=\>'project\_version' %\>

I don’t believe it’s legal HTML to have a div there.

Fred

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 3:53pm UTC](https://www.ruby-forum.com/t/why-render-doesnt-work/157020/3 "2009-01-06T15:53:47Z")

</div>

Frederick C. wrote:

> I don’t believe it’s legal HTML to have a div there.
> 
> Fred

Why? Could you tell me what wrong with my code?

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 3:58pm UTC](https://www.ruby-forum.com/t/why-render-doesnt-work/157020/4 "2009-01-06T15:58:32Z")

</div>

On 6 Jan 2009, at 14:53, Zhao Yi wrote:

> Frederick C. wrote:
> 
> > I don’t believe it’s legal HTML to have a div there.
> > 
> > Fred
> 
> Why? Could you tell me what wrong with my code?

That’s just the way it is, divs aren’t allowed there (just as you  
can’t do

 either). Try putting your html  
through the w3c validator

Fred

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 7, 2009, 2:14am UTC](https://www.ruby-forum.com/t/why-render-doesnt-work/157020/5 "2009-01-07T02:14:50Z")

</div>

Quoting Zhao Yi [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Frederick C. wrote:
> 
> > That’s just the way it is, divs aren’t allowed there (just as you  
> > can’t do
> > 
> > either). Try putting your html  
> > through the w3c validator
> > 
> > Fred  
> > A render must be in an element. If I can’t use div in this case, how can  
> > I render it?

Your element (the

…
) isn’t in a valid place. You have it  
between  
a row and the end of the table. Is it supposed to straddle the table  
boundary? Either move it into the … or outside the table as  
appropriate. Or put it in a table row of its own.

Jeffrey

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 7, 2009, 1:56am UTC](https://www.ruby-forum.com/t/why-render-doesnt-work/157020/6 "2009-01-07T01:56:19Z")

</div>

Frederick C. wrote:

> That’s just the way it is, divs aren’t allowed there (just as you  
> can’t do
> 
> either). Try putting your html  
> through the w3c validator
> 
> Fred  
> A render must be in an element. If I can’t use div in this case, how can  
> I render it?
