# Render partial yields "dynamic constant assignment"

**URL:** <https://www.ruby-forum.com/t/render-partial-yields-dynamic-constant-assignment/138974>\
**Category:** Rails\
**Created:** [May 29, 2008, 5:04pm UTC](https://www.ruby-forum.com/t/render-partial-yields-dynamic-constant-assignment/138974 "2008-05-29T17:04:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [May 29, 2008, 5:04pm UTC](https://www.ruby-forum.com/t/render-partial-yields-dynamic-constant-assignment/138974/1 "2008-05-29T17:04:06Z")

</div>

I’m getting a syntax error when rendering a partial. This is a simple  
html partial with one instance variable inside it. Rendering as a  
“template” instead of as a partial works just fine. The error occurs 3  
lines after the last line of HTML code in the partial. There is no line  
72! Here is the error:

SyntaxError in Building\_blocks#preview  
Showing building\_blocks/\_BB02.html.erb where line #72 raised:

compile error  
C:/Ruby\_Development/sbtool/app/views/building\_blocks/\_BB02.html.erb:-2:  
dynamic constant assignment  
BB02 = local\_assigns[:BB02]  
^  
C:/Ruby\_Development/sbtool/app/views/building\_blocks/\_BB02.html.erb:-1:  
dynamic constant assignment  
BB02\_counter = local\_assigns[:BB02\_counter]

Extracted source (around line #72):  
69:   
70:

Application Trace:  
app/views/building\_blocks/\_BB02.html.erb:72:in `compile_template' app/controllers/building_blocks_controller.rb:99:in`preview’  
script\server:3  
-e:2:in `load’  
-e:2

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [May 29, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/render-partial-yields-dynamic-constant-assignment/138974/2 "2008-05-29T17:20:13Z")

</div>

On 29 May 2008, at 16:04, Corey M. wrote:

> I’m getting a syntax error when rendering a partial. This is a simple  
> html partial with one instance variable inside it. Rendering as a  
> “template” instead of as a partial works just fine. The error  
> occurs 3  
> lines after the last line of HTML code in the partial. There is no  
> line  
> 72! Here is the error:

Don’t start your partial names with a capital letter. rails creates a  
local variable for the object corresponding to the partial and local  
variables can’t start with a capital letter

Fred

–  
My ramblings: [http://www.spacevatican.org](http://www.spacevatican.org)

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [May 29, 2008, 5:27pm UTC](https://www.ruby-forum.com/t/render-partial-yields-dynamic-constant-assignment/138974/3 "2008-05-29T17:27:07Z")

</div>

Frederick C. wrote:

> On 29 May 2008, at 16:04, Corey M. wrote:
> 
> > I’m getting a syntax error when rendering a partial. This is a simple  
> > html partial with one instance variable inside it. Rendering as a  
> > “template” instead of as a partial works just fine. The error  
> > occurs 3  
> > lines after the last line of HTML code in the partial. There is no  
> > line  
> > 72! Here is the error:
> 
> Don’t start your partial names with a capital letter. rails creates a  
> local variable for the object corresponding to the partial and local  
> variables can’t start with a capital letter
> 
> Fred
> 
> –  
> My ramblings: [http://www.spacevatican.org](http://www.spacevatican.org)

Doh! I should know that. Standard ruby “convention”.

Thanks Fred, as always!
