Can someone please help me? I think i'm going crazy! [bug]

hello all…

i’m experiencing what seems to be a bug in rails while trying to pass a
local variable to a partial. i’m referencing code from :

http://www.pointstorm.com/~gavin/partials-doc/classes/ActionView/Partials.html

here’s my code

View:


<%= render_partial ‘report_form’, nil, ‘r’ => ‘1’ %>


i’ve tried the ‘1’ with and without quotes…

Partial:


Criteria <%= r %>

<%= text_field “report”, “phrase#{r}”, :size => 20 %>

<%= link_to “Add Criteria”, :action => “report_builder”, :id => r.to_i+1
%>


and here’s the error i’m getting:


compile error
script/…/config/…/app/views/assets/_report_form.rhtml:-1: syntax
error, unexpected ‘=’, expecting kEND
= local_assigns[:]
^
script/…/config/…/app/views/assets/_report_form.rhtml:-1: syntax
error, unexpected ‘]’, expecting tSTRING_CONTENT or tSTRING_DBEG or
tSTRING_DVAR or tSTRING_END

Extracted source (around line #10):

7:
8: <%= link_to “Add Criteria”, :action => “report_builder”, :id =>
r.to_i+1 %>


this isn’t making any sense to me. as you can see the partial is only 8
lines… not 10. i’m used to getting errors on lines that aren’t there
when i forget to put and ‘end’ tag somewhere… but that’s not the
problem here. can anyone tell me what i’m doing wrong. maybe i’m just
too tired. :slight_smile:

Jon

Try this:

<%= render :partial => ‘report_form’, :locals => { :r => 1} %>

-Bill

Jon D. wrote:

View:
Partial:

compile error
7:
problem here. can anyone tell me what i’m doing wrong. maybe i’m just
too tired. :slight_smile:

Jon


Sincerely,

William P.

Try this:

<%= render :partial => ‘report_form’, :locals => { :r => 1} %>

-Bill

thanks for the suggestion… it didn’t work. do you think it might be a
bug? it seems that nothing works. even if my partial is completely
empty, it still throws an error. :frowning:

Can you paste in the error you are getting when trying my suggestion? I
use this in many places with no issues.

-Bill

Jon D. wrote:

bug? it seems that nothing works. even if my partial is completely
empty, it still throws an error. :frowning:


Sincerely,

William P.

William P. wrote:

Can you paste in the error you are getting when trying my suggestion? I
use this in many places with no issues.

-Bill

compile error
script/…/config/…/app/views/assets/_report_form.rhtml:-2: syntax
error, unexpected ‘=’, expecting kEND
= local_assigns[:]
^
script/…/config/…/app/views/assets/_report_form.rhtml:-2: syntax
error, unexpected ‘]’, expecting tSTRING_CONTENT or tSTRING_DBEG or
tSTRING_DVAR or tSTRING_END

this error isn’t making any sense to me. thanks for your help…

this error isn’t making any sense to me. thanks for your help…

ok i fixed it but you’ll never guess how… my partial was named
_report_form.rhtml… when i changed it to _reportform.rhtml… now it
works! should this be reported somewhere? i’ve never heard that you
can have underscores in the partial name. let me know what you guys
think.

On 5 Nov 2007, at 17:04, Jon D. wrote:

here’s my code

View:


<%= render_partial ‘report_form’, nil, ‘r’ => ‘1’ %>

render_partial is deprecated.
does render :partial => ‘report_form’, :locals => {‘r’ => '1}
work any better ?

Fred

No, there is something else going on here. I use underscores in many
partial names.

-Bill

Jon D. wrote:

this error isn’t making any sense to me. thanks for your help…

ok i fixed it but you’ll never guess how… my partial was named
_report_form.rhtml… when i changed it to _reportform.rhtml… now it
works! should this be reported somewhere? i’ve never heard that you
can have underscores in the partial name. let me know what you guys
think.


Sincerely,

William P.

That appears to be the error from the browser. What is in your logs? I
suspect there is more info waiting in development.log that will help you
on this.

-Bill

Jon D. wrote:

script/…/config/…/app/views/assets/_report_form.rhtml:-2: syntax
error, unexpected ‘=’, expecting kEND
= local_assigns[:]
^
script/…/config/…/app/views/assets/_report_form.rhtml:-2: syntax
error, unexpected ‘]’, expecting tSTRING_CONTENT or tSTRING_DBEG or
tSTRING_DVAR or tSTRING_END

this error isn’t making any sense to me. thanks for your help…


Sincerely,

William P.

Mohit S. wrote:

I’ve used partials like _list_header.rhtml in the past, so it seems a
bit odd to see what you say. I haven’t followed your thread so far but
how are you calling it from your view code?

Cheers
Mohit.

View :


<%= render :partial => ‘reportform’, :locals => { :r => 1} %>


i have also used underscores in my partials. maybe it’s because of the
local variable assignment? i’m mostly dumbfounded by this. thanks
again for your time. :slight_smile: jon

Jon D. wrote:

this error isn’t making any sense to me. thanks for your help…

ok i fixed it but you’ll never guess how… my partial was named
_report_form.rhtml… when i changed it to _reportform.rhtml… now it
works! should this be reported somewhere? i’ve never heard that you
can have underscores in the partial name. let me know what you guys
think.

I’ve used partials like _list_header.rhtml in the past, so it seems a
bit odd to see what you say. I haven’t followed your thread so far but
how are you calling it from your view code?

Cheers
Mohit.

<%= render :partial => ‘report_form’, :locals => { :r => 1} %>

(note the underscore after report)

i changed the partial name to ‘reportform.rhtml’, that’s how i got it to
work :slight_smile: we were just trying to find out why it didn’t work before,
when i did have the underscore in there. man this is getting confusing.

Jon D. wrote:

Like I said, I missed the earlier part of the thread but this is what
the rules are (which I think you know):

:partial => ‘report_form’ —> partial called _report_form.rhtml

:partial => ‘reportform’ —> partial called _reportform.rhtml

I guess somewhere in the debugging you did, an extra underscore got
added or one got removed, and the 2 were not consistent any longer :slight_smile:

Cheers,
Mohit.
11/6/2007 | 1:56 AM.

Jon D. wrote:

View :


<%= render :partial => ‘reportform’, :locals => { :r => 1} %>


Jon, I think that should be:

<%= render :partial => ‘report_form’, :locals => { :r => 1} %>

(note the underscore after report)

Rails won’t insert too many extra underscores for you :wink:

Cheers,
Mohit.
11/6/2007 | 1:49 AM.

Actually, can I see the reportform.rhtml view? I think that is where the
error is coming from. Did you look at development.log to get the full
error and stack trace? If you paste that in, it would be a huge help.

-Bill

Jon D. wrote:

local variable assignment? i’m mostly dumbfounded by this. thanks
again for your time. :slight_smile: jon


Sincerely,

William P.