Forum: Ruby on Rails Select error

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.
Buntin, Seth - KATE (Guest)
on 2006-02-21 23:42
(Received via mailing list)
This code:

<p>

   <label for="resource_type">Type</label><br/>

   <%= select(:resource, :type, %w{ Web Data }, { :include_blank => true
}) %>

</p>



Produces this error:


TypeError in Resources#new


Showing app/views/resources/_form.rhtml where line #6 raised:

wrong argument type String (expected Module)

Extracted source (around line #6):

3:     <legend>Resource General</legend>
4:
5:     <p><label for="resource_type">Type</label><br/>
6:         <%= select(:resource, :type, %w{ Web Data }, { :include_blank
=> true }) %>
7:      </p>
8:
9:     <p><label for="resource_focus_id">Focus</label><br/>





I took it straight out of the Agile Web D. book (except the
:include_blank)



Seth B.

Web Resources Coordinator

Kentucky Academy of Technology Education

Murray State University
Anthony G. (Guest)
on 2006-02-22 17:57
Buntin, Seth - KATE wrote:
> This code:
>
> <p>
>
>    <label for="resource_type">Type</label><br/>
>
>    <%= select(:resource, :type, %w{ Web Data }, { :include_blank => true
> }) %>
>
> </p>
>

You have missed out the options parameter.

select(object, method, choices, options = {}, html_options = {})

 select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id
] }, { :include_blank => true })
Adrian L. (Guest)
on 2006-10-10 02:02
Buntin, Seth - KATE wrote:
> This code:
>
> <p>
>
>    <label for="resource_type">Type</label><br/>
>
>    <%= select(:resource, :type, %w{ Web Data }, { :include_blank => true
> }) %>
>
> </p>
i experienced the same error
i changed :type into :status and then it works fine
i think :type is not allowed in select
Diego L. (Guest)
on 2006-10-10 04:13
(Received via mailing list)
I belive "type" is a method that returns the class of an Object and
its now deprecated.
So you wont be able to use it within your ror app.

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