das ganze reduziert sich bisher bei mir auf die views weil sich das
feld - bei richtiger eingabe - ja wie ein varchar/:string verhält.
und dafür hab ich diese lösung:
------------- 8<------------- 8<------------- 8<------------- 8<-------------
def enum_field(object_name, method, options = {})
col = ActiveRecord::Base.find_by_sql("SHOW COLUMNS FROM
#{object_name.pluralize} LIKE '#{method}'")
col=col[0].instance_values["attributes"]
col=col["Type"]
col=col[5..-2] # get rid of the "enum(" and ")" parts
col.tr!("'","")
col=col.split(",")
ret = "<select name=\"#{object_name}[#{method}]\"
id=\"#{object_name}_#{method}\">\n"
col.each do |enum_entry|
call=eval("@#{object_name}.#{method}")
if call == enum_entry
ret += "<option selected>#{enum_entry}</option>\n"
else
ret += "<option>#{enum_entry}</option>\n"
end
end
ret += "</select>"
return ret
end
------------- 8<------------- 8<------------- 8<------------- 8<-------------
das gefällt mir ganz gut.
@Thomas: mit einem oracle adapter kann ich mangels ahnung,
notwendigkeit etc. leider auch nicht dienen. ich werds mir aber auch
noch ansehen, vielleicht, hab ich es bisher ja einfach falsch
verstanden.
--
N 53° 33.283 E 010° 02.623
http://tinyurl.com/2nplah
_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/mailman/listinfo/rubyonrails-ug