TvE
2006-Sep-04 20:36 UTC
Overriding ActionView::Helpers::InstanceTag::DEFAULT_TEXT_AREA_OPTIONS
What is the best way to override some of the FormHelper default options? Right now I''m adding this to the beginning of my environment.rb: ActionView::Helpers::InstanceTag::DEFAULT_TEXT_AREA_OPTIONS = { "cols" => 80, "rows" => 5 } Is that the way it''s supposed to be done? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Rha7.Com
2007-Nov-14 07:37 UTC
Re: Overriding ActionView::Helpers::InstanceTag::DEFAULT_TEXT_AREA_OPTIONS
Actually, you can override it with the right statements. The constant is defined as: http://caboo.se/doc/classes/ActionView/Helpers/InstanceTag.html http://caboo.se/doc/classes/ActionView/Helpers/InstanceTag.html DEFAULT_TEXT_AREA_OPTIONS = { "cols" => 40, "rows" => 20 }.freeze unless const_defined?(:DEFAULT_TEXT_AREA_OPTIONS) The key is the "unless const_defined?(...)". It says that the constant should be defined and frozen, UNLESS it is aready defined. How do you define it before ActionView::Helpers::InstanceTag is defined?. Well, just define it at the beginning of environment.rb, however, since neither ActionView, Helpers or InstanceTag is defined yet, we must define them fully with Module/Class...End blocks like this: module ActionView module Helpers class InstanceTag DEFAULT_TEXT_AREA_OPTIONS = { :cols => 60, :rows => 10 } end end end So, just add the code above at the top of your config/environment.rb, and you should be all set and warning-free. I hope this helps someone. Gabriel Medina. http://www.dottut.com/ http://www.dottut.com/ -- View this message in context: http://www.nabble.com/Overriding-ActionView%3A%3AHelpers%3A%3AInstanceTag%3A%3ADEFAULT_TEXT_AREA_OPTIONS-tf2217303.html#a13741511 Sent from the RubyOnRails Users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- overriding constants
- Make `ActionView::Helpers::InstanceTag#tag_id`, `ActionView::Helpers::InstanceTag#tag_id_with_index(index)` public?
- ActionView::Helpers::InstanceTag#to_date_tag help
- RE: Why class InstanceTag is defined at 4 different places inRails
- InstanceTag