Forum: Ruby on Rails select list error - following Agile guide

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.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-07 22:52
(Received via mailing list)
I would swear that I am tracking exactly the method used in Agile
book...

TypeError in Placements#edit
Showing app/views/placements/_form.rhtml where line #33 raised:

wrong argument type String (expected Module)

Extracted source (around line #33):

30:   <tr>
31:     <td><label for "type">Type</label></br><%=
32:            options = [["Select Program Type", ""]] +
Placement::PROGRAM_TYPES
33:            select("placement", "type", options) %>
34:         </td>
35:     <td></td>
36:     <td>

inside of placement.rb (model)

  PROGRAM_TYPES = [
    [ "PAH",        "PAH" ],
    [ "16 Hour",    "16 Hour" ],
    [ "24 Hour",    "24 Hour" ],
    [ "24 Hour DD", "24 Hour DD" ]
  ].freeze

Why isn't this working?

Craig
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 Kent Sibilev (Guest)
on 2006-02-07 23:04
(Received via mailing list)
'type' attribute is reserved for STI (single table inheritance). Try
to change the name of this attribute from 'type' to something else and
check whether it helps.

Kent.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-07 23:16
(Received via mailing list)
duh - gasp! always overlook the obvious is my motto.

At least I typed it right.

thanks

Craig
42292bf8a0acbc98862d9306b501275d?d=identicon&s=25 Daniel Waite (rabbitcreative)
on 2006-02-08 20:52
(Received via mailing list)
Yes, "type" is meant for use with STI, but, right now I'm having
similar trouble.

My table, advertisers, uses the special "type" field. I want users to
be able to select the type of advertiser during creation via a select
box. Is this possible? (I assume it would be possible using
select_tag(), but I'd rather use select().)

The types of advertisers are stored as string in an array in
environment.rb. The code I'm using works fine - I've tested it in
console.rb. But here it is anyway...

<%= select 'advertiser', 'type', ADVERTISERS.map { |at| [ at, at ] } %>

Has anyone else run into this problem? Is it possible to use the
"type" field like this?

- Rabbit

---
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-08 21:20
(Received via mailing list)
Since it's a reserved name, you are always gonna struggle with using a
table with a column named 'type' - that was what I gathered and so I
simply renamed the column and moved on.

as for a selection list of values...this has worked for me...

<%= options = [[ 'Select Type', '']] + model::METHOD, select
'controller', 'field', options %>

ie...my model and controller being 'placement' and my METHOD being a
list of values in the placement model called "PROGRAM_TYPES"...

<%= options = [[ 'Select Type', '']] + placement::PROGRAM_TYPES select
'placement', 'pltype', options %>

Craig
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 Kent Sibilev (Guest)
on 2006-02-08 21:29
(Received via mailing list)
Actually, you can change the default name of this column from 'type'
to something else by overriding the inheritance_column method of the
ActiveRecord::Base class.

Kent.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-08 21:41
(Received via mailing list)
yeah but it was a part of a bunch of new tables tossed together without
any meaningful data or significant amount of coding (since the amount of
coding I have gotten done is directly proportionate to my lack of
knowledge which inch by inch grows and in another 5 years...I think I
will understand things). If it were an existing table with data, I might
have opted for that but it did seem to me when that was first brought up
that I needed to bail on the column name 'type' since seemed to be the
type of thing that would aggravate me forever in a million different
ways...including outside of the ruby/rails environment.

;-)

Thanks

Craig
42292bf8a0acbc98862d9306b501275d?d=identicon&s=25 Daniel Waite (rabbitcreative)
on 2006-02-08 22:34
(Received via mailing list)
I _want_ to use the type column's special attributes. Maybe I can't.

Oh well.

- Rabbit

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