selectboxes with references to other objects

0 views
Skip to first unread message

Vorik

unread,
Apr 16, 2007, 2:45:45 AM4/16/07
to ActiveScaffold : Ruby on Rails plugin
Hi!

I'm gettings some strange stuff in my selectboxes that represent
belongs_to and has_many relationships:

#<Opleiding:0xb76dc6e0>

I'd really like this field(selectbox) to contain the name of the
'opleiding', instead of the object-id.

How can I override this?

Many thanks,
Ger Apeldoorn

Vorik

unread,
Apr 16, 2007, 3:23:52 AM4/16/07
to ActiveScaffold : Ruby on Rails plugin
I've found out that if I add a 'name' column for the referenced
object, this gets put in the selectbox. However, my table has a 'naam'
field. Is it possible to override this without changing the column
name?

Thanks,
Ger.

Han Holl

unread,
Apr 16, 2007, 5:04:51 AM4/16/07
to ActiveScaffold : Ruby on Rails plugin

On Apr 16, 9:23 am, "Vorik" <goo...@gerapeldoorn.nl> wrote:
> I've found out that if I add a 'name' column for the referenced
> object, this gets put in the selectbox. However, my table has a 'naam'
> field. Is it possible to override this without changing the column
> name?
>

You want:
def to_label
self.naam
end

in your model.

Cheers,

Han Holl

Vorik

unread,
Apr 16, 2007, 1:31:47 PM4/16/07
to ActiveScaffold : Ruby on Rails plugin
Thanks a lot, i'll try it out tomorrow!!

Greetings,
Ger.

Reply all
Reply to author
Forward
0 new messages