In my view I render a partial.
The name of the partial is constructed by the name of a product page.
<%= render :partial => "product_pages/" + selected.headline %>
In the test case the headline is “electronics”.
So I also tried:
<%= render :partial => "product_pages/electronics"
For testing the partial view looks like this:
<p>Test</p>
Now I get this error I do not understand:
ActionView::Template::Error (/var/www/*****/app/views/product_pages/_Elektro
nik.html.erb:1: dynamic constant assignment
...r = @output_buffer;Elektronik = local_assigns[:Elektronik];;...
... ^):
1: <p>Test</p>
app/views/pages/_content.html.erb:13:in `_app_views_pages__content_html_erb__4
0580468132849538_266915680_1201196437383914942'
app/views/pages/index.html.erb:3:in `_app_views_pages_index_html_erb__43007964
38685262523_267219620_562910368159856764'
You need to
downcaseyour headline:This is because you’re going to be rendering a partial like this:
product_pages/Elektronik, and when you callrender :partialit’ll attempt to define a local variable that has the same name as the partial, which is why you’re getting this error: the code isn’t defining a local variable but is actually defining a constant.If you
downcaseit, it will define a local variable rather than this constant.