I''m using the datetime_select in an application of mine and it''s working great, except there doesn''t seem to be any way to have the hours show up with the meridian indicator (AM/PM) rather than 24hr time. I rewrote the select_hour function to display AM / PM, but I''m not sure how to open the module back up (ActionView::Helpers::DateHelper) and redefine select_hour. I''m assuming I just redefine it like this: module ActionView module Helpers module DateHelper def select_hour # snip end end end end Where would I put this in my Rails filesystem? How do I get this executed before the view gets rendered? Is this the right way to be thinking about it? -- Brad Ediger 866-EDIGERS
I think that belongs in lib, though it''s quite possible it could exist in application.rb as well. -- -- Tom Mornini On Oct 6, 2005, at 2:42 PM, Brad Ediger wrote:> I''m using the datetime_select in an application of mine and it''s > working great, except there doesn''t seem to be any way to have the > hours show up with the meridian indicator (AM/PM) rather than 24hr > time. I rewrote the select_hour function to display AM / PM, but > I''m not sure how to open the module back up > (ActionView::Helpers::DateHelper) and redefine select_hour. > > I''m assuming I just redefine it like this: > > module ActionView > module Helpers > module DateHelper > def select_hour > # snip > end > end > end > end > > Where would I put this in my Rails filesystem? How do I get this > executed before the view gets rendered? Is this the right way to be > thinking about it? > > -- > Brad Ediger > 866-EDIGERS > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Does anyone have any experience overriding Rails code (especially helpers) with custom application-specific code? I''ve placed my override code in lib, but it''s not overriding the functions like I want it to. I did a require_dependency ''lib/ fix_date'' at the end of my config/environment.rb. I even threw in a puts ''Here'' statement to ensure the lib was being loaded (it shows on the console when the server is started). But it still uses the old functionality; the code I added has no effect. I''d appreciate any suggestions or pointers. Thanks, -- Brad Ediger 866-EDIGERS On Oct 6, 2005, at 7:16 PM, Tom Mornini wrote:> I think that belongs in lib, though it''s quite possible it could > exist in application.rb as well. > > -- > -- Tom Mornini > > > On Oct 6, 2005, at 2:42 PM, Brad Ediger wrote: > > >> I''m using the datetime_select in an application of mine and it''s >> working great, except there doesn''t seem to be any way to have the >> hours show up with the meridian indicator (AM/PM) rather than 24hr >> time. I rewrote the select_hour function to display AM / PM, but >> I''m not sure how to open the module back up >> (ActionView::Helpers::DateHelper) and redefine select_hour. >> >> I''m assuming I just redefine it like this: >> >> module ActionView >> module Helpers >> module DateHelper >> def select_hour >> # snip >> end >> end >> end >> end >> >> Where would I put this in my Rails filesystem? How do I get this >> executed before the view gets rendered? Is this the right way to >> be thinking about it? >> >> -- >> Brad Ediger >> 866-EDIGERS >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
(sheepish grin) Never mind, I was using the constant ActionPack instead of ActionView. :-) Thanks -- Brad Ediger 866-EDIGERS On Oct 10, 2005, at 5:04 PM, Brad Ediger wrote:> Does anyone have any experience overriding Rails code (especially > helpers) with custom application-specific code? > > I''ve placed my override code in lib, but it''s not overriding the > functions like I want it to. I did a require_dependency ''lib/ > fix_date'' at the end of my config/environment.rb. I even threw in a > puts ''Here'' statement to ensure the lib was being loaded (it shows > on the console when the server is started). But it still uses the > old functionality; the code I added has no effect. > > I''d appreciate any suggestions or pointers. > > Thanks, > -- > Brad Ediger > 866-EDIGERS > > > On Oct 6, 2005, at 7:16 PM, Tom Mornini wrote: > > >> I think that belongs in lib, though it''s quite possible it could >> exist in application.rb as well. >> >> -- >> -- Tom Mornini >> >> >> On Oct 6, 2005, at 2:42 PM, Brad Ediger wrote: >> >> >> >>> I''m using the datetime_select in an application of mine and it''s >>> working great, except there doesn''t seem to be any way to have >>> the hours show up with the meridian indicator (AM/PM) rather than >>> 24hr time. I rewrote the select_hour function to display AM / PM, >>> but I''m not sure how to open the module back up >>> (ActionView::Helpers::DateHelper) and redefine select_hour. >>> >>> I''m assuming I just redefine it like this: >>> >>> module ActionView >>> module Helpers >>> module DateHelper >>> def select_hour >>> # snip >>> end >>> end >>> end >>> end >>> >>> Where would I put this in my Rails filesystem? How do I get this >>> executed before the view gets rendered? Is this the right way to >>> be thinking about it? >>> >>> -- >>> Brad Ediger >>> 866-EDIGERS >>> >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >