Rails Tag Helper default values

I was tooling through a form setting text_field sizes ( the default of :size => 30 is a bit big for me ) and my “cut-n-paste is bad” alarm when off. There had to be a better way to set the form tag defaults. A few minutes on Google and Noobkit provided an answer:

InstanceTag::DEFAULT_*

For instance,

ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS = { :size => 15 }

in my environment.rb sets the size of all undefined textboxes to 15 instead of the default of 30. Other defaults include:

{ :discard_type => true }.freeze unless const_defined?( :D EFAULT_DATE_OPTIONS)

{ "size" => 30 }.freeze unless const_defined?( :D EFAULT_FIELD_OPTIONS)

{ }.freeze unless const_defined?( :D EFAULT_RADIO_OPTIONS)

{ "cols" => 40, "rows" => 20 }.freeze unless const_defined?( :D EFAULT_TEXT_AREA_OPTIONS)
This entry was posted in Coding. Bookmark the permalink.

Leave a Reply