Hi. I found some behaviour that feels weird. I dont know if it's my
fault or its a bug. Here we go.
I want a on my view a case statemente that puts one input or another,
based on the type of the attribute im handling.
In plain old ruby, case allows to return a value, like this
car = "Patriot"
manufacturer = case car
   when "Focus" then "Ford"
   when "Navigator" then "Lincoln"
   when "Camry" then "Toyota"
   when "Civic" then "Honda"
   when "Patriot" then "Jeep"
   when "Jetta" then "VW"
   when "Ceyene" then "Porsche"
   when "Outback" then "Subaru"
   when "520i" then "BMW"
   when "Tundra" then "Nissan"
   else "Unknown"
end

So, i thought that its possible to do this:

= case klass.columns_hash[field.to_s].type
- when :string then form.text_field field, :value => default
- when :integer then form.select field, COLLECTIONS[field], :selected
=> default
- when :date then form.date_select field, :order
=>[:day,:month,:year] ,:value => default
- else "Other type"

But it crash. The most strange thing: i can assign the return value to
a variable and then show that variable:

- x = case klass.columns_hash[field.to_s].type
- when :string then form.text_field field, :value => default
- when :integer then form.select field, COLLECTIONS[field], :selected
=> default
- when :date then form.date_select field, :order
=>[:day,:month,:year] ,:value => default
- else "Other type
= x

Seems ilogic for me. I'm doing something wrong?


-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to