# Multiple-select no method found?

**URL:** <https://www.ruby-forum.com/t/multiple-select-no-method-found/222866>\
**Category:** Rails\
**Created:** [September 13, 2012, 8:10am UTC](https://www.ruby-forum.com/t/multiple-select-no-method-found/222866 "2012-09-13T08:10:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 13, 2012, 8:10am UTC](https://www.ruby-forum.com/t/multiple-select-no-method-found/222866/1 "2012-09-13T08:10:50Z")

</div>

Rails 3.1.3  
latest formtastic

My app requires dynamic select forms, so I have models

class Departure \< ActiveRecord::Base  
has\_many :airlines  
has\_many :destinations, :through =\> :airlines  
end

class Destination \< ActiveRecord::Base  
has\_many :airlines  
has\_many :departures, :throught =\> airlines  
end

class Airline \< ActiveRecord::Base  
belongs\_to :departure  
belongs\_to :destination  
end

And using Formtastic,

\<%= semantic\_form\_for @plan, :remote=\>true do |f| %\>  
\<%= f.inputs do %\>  
\<%= f.input :departure,  
:collection=\>Departure.find(:all, :order=\>:city).collect{ |c|  
[c.city,c.id]},  
:required=\>true %\>

  
\<%= render :partial =\> ‘destination’ %\>  

```
<div id="airlineCompany">
  <%= render :partial => 'airline' %> <======HERE!!!!
</div>

<%= f.action :submit, :as => :button %>

```

\<% end %\>  
\<% end %\>

and JavaScript is ready as well for Ajax responses.

And this works if there is no partial, ‘\_airline.html.erb’ part!

Adding the partial \_airline.html.erb raises an error,

\<%= semantic\_form\_for “plan”, :remote =\> true do |f| %\>  
\<%= f.inputs do %\>  
\<% if !@airlines.blank? %\>  
\<%= f.input :airline, :collection=\>airlines.collect{ |s|  
[s.company,s.id]} %\>  
\<% else %\>  
\<%= f.input :airline, :collection=\>[] %\>  
\<% end %\>  
\<% end %\>  
\<% end %\>

#error  
ActionView::Template::Error (undefined method `airline’ for  
#Plan:0x000001037e66f8):  
3: \<% if !@airlines.blank? %\>  
4: \<%= f.input :airline, :collection=\>airlines.collect{ |s|  
[s.company,s.id]} %\>  
5: \<% else %\>  
6: \<%= f.input :airline, :collection=\>[] %\>  
7: \<% end %\>  
8: \<% end %\>  
9: \<% end %\>

I don’t understand the error message because there is no method used in  
this particular partial.  
And similarly, the controller does not have such method, ‘airilne’.

Can anyone guess the cause of this error?

Thanks

soichi

---

<div class="post-metadata">

**Author:** ![soujiro0725](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@soujiro0725](https://www.ruby-forum.com/u/soujiro0725)\
**Post date:** [September 13, 2012, 9:57am UTC](https://www.ruby-forum.com/t/multiple-select-no-method-found/222866/2 "2012-09-13T09:57:18Z")

</div>

On 13 September 2012 07:10, Soichi I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> And using Formtastic,
> 
> ```
> <%= f.input :airline, :collection=>[] %>
> 
> ```
> 
> [s.company,s.id]} %\>  
> The line above expects there to be a method airline in the Plan object  
> that you have created the form for.

Colin

---

<div class="post-metadata">

**Author:** ![soujiro0725](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@soujiro0725](https://www.ruby-forum.com/u/soujiro0725)\
**Post date:** [September 13, 2012, 12:45pm UTC](https://www.ruby-forum.com/t/multiple-select-no-method-found/222866/3 "2012-09-13T12:45:11Z")

</div>

> #error  
> ActionView::Template::Error (undefined method `airline’ for  
> #Plan:0x000001037e66f8):  
> 3: \<% if !@airlines.blank? %\>  
> 4: \<%= f.input :airline, :collection=\>airlines.collect{ |s|  
> [s.company,s.id]} %\>  
> 5: \<% else %\>  
> 6: \<%= f.input :airline, :collection=\> %\>  
> 7: \<% end %\>  
> 8: \<% end %\>  
> 9: \<% end %\>

Hi Soichi,

Kindly check whether ‘airline’ is there in plan model or not and check  
if you have spelled it correctly..

Thanks,

P.Angeline
