Hi, I''m having some trouble overriding/defining the default_field_options constant without raising a warning. I''ve tried adding the code to do it in an initializer but that produces a warning (because the constant is already frozen), after some googling I found a recommendation to put it in the environment.rb file but that then that throws uninitialized constant ActionView (NameError) which prevents the app from starting all together. Any solution to this would be excellent. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You cannot override constants (i assumeyou want to put a different value in it) without getting a warning, hence they are called Constant. In java you cannot override them at all. thank ruby for just throwing a warning. If you want to initialize it with your new value, just see in the code where it is being declared and put your new value there. thatr way you wont get the warning. On Mar 15, 5:07 pm, Dru <dru.re...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m having some trouble overriding/defining the default_field_options > constant without raising a warning. I''ve tried adding the code to do > it in an initializer but that produces a warning (because the constant > is already frozen), after some googling I found a recommendation to > put it in the environment.rb file but that then that throws > > uninitialized constant ActionView (NameError) > > which prevents the app from starting all together. > > Any solution to this would be excellent. Thanks.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ah right okay, I shall have to do that then. Thanks for your help! It seems odd you can''t configure this more easily though as it seems like one of the obvious ones you would want to tweak. It''s annoying for me in particular as I have 2 projects using html5 so removing the size attribute is all I wanted to do! It seems strange to me that size would be a default value in the first place with css being the more appropriate place to do such a thing as well. On Mar 16, 11:10 am, "\"Wolas!\"" <jcpen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You cannot override constants (i assumeyou want to put a different > value in it) without getting a warning, hence they are called > Constant. In java you cannot override them at all. thank ruby for just > throwing a warning. > > If you want to initialize it with your new value, just see in the code > where it is being declared and put your new value there. thatr way you > wont get the warning. > > On Mar 15, 5:07 pm, Dru <dru.re...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > I''m having some trouble overriding/defining the default_field_options > > constant without raising a warning. I''ve tried adding the code to do > > it in an initializer but that produces a warning (because the constant > > is already frozen), after some googling I found a recommendation to > > put it in the environment.rb file but that then that throws > > > uninitialized constant ActionView (NameError) > > > which prevents the app from starting all together. > > > Any solution to this would be excellent. Thanks.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe thats a good comment to tell to the ones writing the software, sometimes when you write these things you are not sure what people will want to end up tweaking. It is the constant burden of the programmer: you write a piece of software for somethgn and it ends up being used in a completely different way. but hey, its mroe fun this way On Mar 16, 9:19 pm, Dru <dru.re...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ah right okay, I shall have to do that then. Thanks for your help! > > It seems odd you can''t configure this more easily though as it seems > like one of the obvious ones you would want to tweak. It''s annoying > for me in particular as I have 2 projects using html5 so removing the > size attribute is all I wanted to do! It seems strange to me that size > would be a default value in the first place with css being the more > appropriate place to do such a thing as well. > > On Mar 16, 11:10 am, "\"Wolas!\"" <jcpen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You cannot override constants (i assumeyou want to put a different > > value in it) without getting a warning, hence they are called > > Constant. In java you cannot override them at all. thank ruby for just > > throwing a warning. > > > If you want to initialize it with your new value, just see in the code > > where it is being declared and put your new value there. thatr way you > > wont get the warning. > > > On Mar 15, 5:07 pm, Dru <dru.re...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > > I''m having some trouble overriding/defining the default_field_options > > > constant without raising a warning. I''ve tried adding the code to do > > > it in an initializer but that produces a warning (because the constant > > > is already frozen), after some googling I found a recommendation to > > > put it in the environment.rb file but that then that throws > > > > uninitialized constant ActionView (NameError) > > > > which prevents the app from starting all together. > > > > Any solution to this would be excellent. Thanks.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, The right way to do this is actually to just define the ActionView::Helpers::InstanceTag class in a plugin (as ActionView has not been loaded yet), and set DEFAULT_FIELD_OPTIONS there. In short, create a vender/plugins/default_options/init.rb with the following: module ActionView module Helpers class InstanceTag DEFAULT_FIELD_OPTIONS = {} end end end On Mar 17, 6:52 am, "\"Wolas!\"" <jcpen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Maybe thats a good comment to tell to the ones writing the software, > sometimes when you write these things you are not sure what people > will want to end up tweaking. It is the constant burden of the > programmer: you write a piece of software for somethgn and it ends up > being used in a completely different way. but hey, its mroe fun this > way > > On Mar 16, 9:19 pm, Dru <dru.re...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Ah right okay, I shall have to do that then. Thanks for your help! > > > It seems odd you can''t configure this more easily though as it seems > > like one of the obvious ones you would want to tweak. It''s annoying > > for me in particular as I have 2 projects using html5 so removing the > > size attribute is all I wanted to do! It seems strange to me that size > > would be a default value in the first place with css being the more > > appropriate place to do such a thing as well. > > > On Mar 16, 11:10 am, "\"Wolas!\"" <jcpen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > You cannot override constants (i assumeyou want to put a different > > > value in it) without getting a warning, hence they are called > > > Constant. In java you cannot override them at all. thank ruby for just > > > throwing a warning. > > > > If you want to initialize it with your new value, just see in the code > > > where it is being declared and put your new value there. thatr way you > > > wont get the warning. > > > > On Mar 15, 5:07 pm, Dru <dru.re...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > > > I''m having some trouble overriding/defining the default_field_options > > > > constant without raising a warning. I''ve tried adding the code to do > > > > it in an initializer but that produces a warning (because the constant > > > > is already frozen), after some googling I found a recommendation to > > > > put it in the environment.rb file but that then that throws > > > > > uninitialized constant ActionView (NameError) > > > > > which prevents the app from starting all together. > > > > > Any solution to this would be excellent. Thanks.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This did not work for me on rails 2.3.2 but got me on the right track. Create a file named vendor/plugins/default_options/init.rb that contains the following: require "default_options" Create a file named vendor/plugins/default_options/lib/ default_options.rb that contains the following: module ActionView module Helpers class InstanceTag DEFAULT_FIELD_OPTIONS = { } end end end On Mar 19, 12:59 am, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > The right way to do this is actually to just define the > ActionView::Helpers::InstanceTag class in a plugin (as ActionView has > not been loaded yet), and set DEFAULT_FIELD_OPTIONS there. In short, > create a vender/plugins/default_options/init.rb with the following: > > module ActionView > module Helpers > class InstanceTag > DEFAULT_FIELD_OPTIONS = {} > end > end > end