This is a bug, but it's fixed in master. Since this is a pretty obscure case, I don't think it's worth the effort to fix it in stable as well. You should probably move your case statement to a helper method anyway.
On Fri, Nov 19, 2010 at 11:35 AM, Miguel.camba <[email protected]>wrote: > 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] <haml%[email protected]>. > For more options, visit this group at > http://groups.google.com/group/haml?hl=en. > > -- 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.
