Tuesday, October 16, 2012

[Rails] Nested partial model input forms:

Rails 3.1.3


I have a model, "Plan" that has columns :flight_name_id(integer).
From the user point of view, searching flights from the places of
departure and destination is in fact logically reasonable. So, my forms
ask users to input places first, then Ajax updates the available flight
plans in the select forms that follow. (Ajax functionality works well,
though)

But "Plan" model only needs flight_name to be stored, so both departure
and destination forms should not be model oriented.
The following code gives an error,

undefined method `departure_id'


<%= semantic_form_for @plan do |f| %>
<%= f.inputs do %>
<%= f.input :departure_id, :as => :select,
:collection => City.find(:all, :order=>:name).collect{ |c|
[c.name,c.id]},
:required=>true %>
<div id="destinationCity">
<%= render :partial => 'destination' %>
</div>
<div id="flight_name">
<%= render :partial => 'flight_name' %>
</div>
...

Certainly, a similar error will appear for destination as well even if
this error is resolved.

Somehow, I need a set of nested forms that is a mixture of form_for and
form_tag (?) if I am correct.

My question is :

How can I make a collection of select forms including both form_tag
and form_for ?

Thanks

soichi

--
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 https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate