I've been spending a great deal of time chasing this problem. Hopefully
someone sees something obvious I'm doing wrong. Basically anytime I try
to call fields_for from an RJS file or within a partial in the RJS file,
I get the following error. My goal is simply to load a partial into a
div. The fields in this partial require fields_for though. And that's
where the problem lies.
ActionView::TemplateError (undefined method `fields_for' for
"#<ActionView::Helpers::FormBuilder:0x944ea28>":String) on line #3 of
app/views/trials/observe.rjs:
1: page.alert('before')
2: test_func = pluralize(6, 'cat')
3: @form.fields_for :org_detail do |w|
4: page['section_two'].replace_html :partial => "mypartial",
:locals => { :f => w }
5: end
6: page.alert('after')
As you can see, the pluralize method seems to work fine, but fields_for
always returns this exception. If I run the fields_for code directly in
my main view HTML file it works fine. However, calling through the RJS
file always fails.
As a work around, I tried setting the fields_for at the highest level
and passing in the fields_for object into the RJS file. However, this
results in the template error undefined method `label'. This is in
regards to the first f.label call in the partial.
Basically it seems that the RJS is choking on any/all form helpers.
My prototype version is 1.6.0.1. Rails 2.3.5. Ruby 1.8.6 or 1.8.7
Any help would be greatly appreciated!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment