mike
May 10, 2010, 6:26pm
1
Can anybody take a quick look at the following problem, occurring with
beta3 on Ruby 1.9.2 ?
gistfile1.rb
# Example in scaffold-generated index view
# Fails
<%= link_to 'Show', entity %>
# Error:
# syntax error, unexpected tIVAR, expecting keyword_do or '{' or '('
# ..._to 'Show', entity @output_buffer.safe_concat('</td>
# Works
This file has been truncated. show original
I used the scaffold generator for the above, so this is just using
defaults (the example is in an index view; specifying an action works
but the shorter version doesn’t).
Also, ‘entity’ does have a primary key.
mike
May 11, 2010, 1:24am
2
This is weird.
Check this out:
See how “link_to ‘Show’” is output (Line 39)? Especially compared to
the other link_to calls?
I changed my view template to the following and it works:
gistfile1.rb
<td><%= link_to 'Show', todo %></td>
# Source output from ActionView::Template's compile method, looping on index view of default scaffolding template via call above
# Result with 'tod', works
@output_buffer.safe_concat('</td>\n <td>');@output_buffer.append= ( link_to 'Show', tod );@output_buffer.safe_concat('</td>\n <td>');
# Result with 'todo', works no
@output_buffer.safe_concat('</td>\n <td>');@output_buffer.append= link_to 'Show', todo @output_buffer.safe_concat('</td>\n <td>');
In other words, I just threw a semi-colon in there and it works. I
don’t know exactly where this should be fixed . . .
mike
May 11, 2010, 3:07am
3
I updated the gist with additional information:
gistfile1.rb
<td><%= link_to 'Show', todo %></td>
# Source output from ActionView::Template's compile method, looping on index view of default scaffolding template via call above
# Result with 'tod', works
@output_buffer.safe_concat('</td>\n <td>');@output_buffer.append= ( link_to 'Show', tod );@output_buffer.safe_concat('</td>\n <td>');
# Result with 'todo', works no
@output_buffer.safe_concat('</td>\n <td>');@output_buffer.append= link_to 'Show', todo @output_buffer.safe_concat('</td>\n <td>');
I’m still drilling down into this but the problem is happening inside
the erubis gem when the template is parsed.
When the variable name is ‘todx’ the output includes:
@output_buffer.safe_concat (‘\n ’);
@output_buffer.append= ( link_to ‘Show’, todx );
@output_buffer.safe_concat (‘\n ’);
But when the variable name is ‘todo’ the output is:
@output_buffer.safe_concat (‘\n ’);
@output_buffer.append= link_to ‘Show’, todo
@output_buffer.safe_concat (‘\n ’);
It’s mangled; I wonder if it’s matching “do” somewhere?
mike
May 11, 2010, 3:43am
4
Okay, last one.
I spoke too soon. It wasn’t in the erubis gem, but a call back to
ActionView::Template::Handlers::Erubis’s add_expr_literal method and a
false match on the pattern BLOCK_EXPR. See:
I think the do pattern may need word boundaries or whitespace
characters surrounding it. I should probably report this
somewhere . . .