Forum: Rails Germany Rails 1.2.6 - Default "zieht" nicht

Posted by Thorsten Schmidt (Guest)
on 2009-02-27 15:19
(Received via mailing list)
Hallo,

ich habe hier leider ein kleines Problem:
Wir haben in unserer Anwendung Kontakte und Kontakt-Typen.
Der Code sieht etwa so aus

class Contact < ActiveRecord::Base
   belongs_to :contact_type
end

Das Feld contact_type_id ist in MySQL per Default auf "4" gesetzt. Dies
"zieht" auch beim Anlegen eines neuen Objekts:

ruby script/console
loading production environment.
 > c = Contact.new
=> #<Contact:0xb76b2df0 @attributes={"contact_type_id"=>4, (...)},
@new_record=true>

In der view gibt es jetzt eine Select-Box für dieses Feld:
             <%= contact.select :contact_type_id,
ContactType.find(:all).collect {|c| [c.short, c.id]} %>

Hier zieht der default aber nicht mehr. D.h. der default in der
DropDown-Liste ist das Elemente mit der höchsten ID (oder, k.A. woher
das eigentlich kommt das Element was zuletzt in der Maske genutzt wurde)

Wo geht der default verloren?

Danke,
Bis dene
Thorsten.
Posted by Andreas Roedl (Guest)
on 2009-02-27 15:22
(Received via mailing list)
Hallo,

On Fri, Feb 27, 2009 at 3:18 PM, Thorsten Schmidt 
<meine_mailings@web.de> wrote:

> k.A. woher das eigentlich kommt das Element was zuletzt in der Maske genutzt wurde)

Ich hoffe mal nicht, dass Dein Browser da intelligent sein will und
das Form für Dich ausfüllt und dabei die Drop-Down-Box auf den zuletzt
gesetzten Wert setzt...



Andreas Roedl
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.