Forum: Ruby on Rails form_for with partial using do |@f|

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Richard S. (Guest)
on 2008-12-02 04:03
Is it possible to pass this FormBuilder object to a controller and then
back to a partial?


I have a form rendering a partial that i would like to update with a
call to my controller based on user selectable parameters, but when the
AJAX comes back, i get this error message because i cannot pass a form
builder object between the controller and the view:

"undefined method `text_area' for
"#<ActionView::Helpers::FormBuilder:0x12c4038>":String"


My View looks like this:

<% form_for @phrase, :action => 'foo' do  |@f| -%>

         <%= select_tag(:language,
options_for_select(["Chinese","English"],
                          :onchange=> remote_function(:with =>
                          "'language='+this.value",
                          :update => 'slang_form_partial',
                          :url => {:action => :something,  :form => @f}
)) %>

     <%= render :partial => 'forms/slang_form_partial'%>

<%= @f.submit %>



In my controller i have something that looks like this:

  def something
      @default_language = params[:language]
      @f = params[:form]
      render :partial => 'forms/slang_form_partial'
    end





Is it possible to pass this FormBuilder object to a controller and then
back to a partial? Rails 2.1.0 and Ruby 1.8.6.
Frederick C. (Guest)
on 2008-12-02 11:54
(Received via mailing list)
On 2 Dec 2008, at 02:03, Richard S. wrote:

>
>
> Is it possible to pass this FormBuilder object to a controller and
> then
> back to a partial?
>
What you are doing can't work. You can't pass arbitrary ruby objects
as params to a url.

Fred
This topic is locked and can not be replied to.