I created a file ./lib/action_view/helpers/asset_tag_helper.rb and put in it only the method I want to override. like this module ActionView module Helpers #:nodoc: module AssetTagHelper def image_path(source) compute_public_path(source, ''images'') end end end end But as soon I try this all the others methods from the overriden module are not available anymore. Any idea? -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
On 28 Oct 2008, at 17:46, Rémi Gagnon <rails-mailing-list@andreas- s.net> wrote:> > I created a file ./lib/action_view/helpers/asset_tag_helper.rb > > and put in it only the method I want to override. like this >Don''t. Create lib/my_module.rb and then include MyModule into ActionView::Base. Or it might be more convenient to do this in application_helper> module ActionView > module Helpers #:nodoc: > module AssetTagHelper > def image_path(source) > compute_public_path(source, ''images'') > end > end > end > end > > But as soon I try this all the others methods from the overriden > module > are not available anymore. > > Any idea? > -- > Posted via http://www.ruby-forum.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you, you are really right I should put it in my application_helper. But Here we will have a lot of projets and I want to share this kind of changes to all teams. So that''s why I would like to ultimatly put it in a gem. So I''m curious to see how you would include mymodule on ActionView::Base. Thanks in advance Frederick Cheung wrote:> On 28 Oct 2008, at 17:46, Rémi Gagnon <rails-mailing-list@andreas- > s.net> wrote: > >> >> I created a file ./lib/action_view/helpers/asset_tag_helper.rb >> >> and put in it only the method I want to override. like this >> > Don''t. Create lib/my_module.rb and then include MyModule into > ActionView::Base. Or it might be more convenient to do this in > application_helper-- Posted via http://www.ruby-forum.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 28, 6:18 pm, Rémi Gagnon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thank you, you are really right I should put it in my > application_helper. But Here we will have a lot of projets and I want > to share this kind of changes to all teams. So that''s why I would like > to ultimatly put it in a gem. > > So I''m curious to see how you would include mymodule on > ActionView::Base. >ActionView::Base.send :include, MyModule With a plugin you''d typically put this in the plugin''s init.rb Fred> Thanks in advance > > Frederick Cheung wrote: > > On 28 Oct 2008, at 17:46, Rémi Gagnon <rails-mailing-list@andreas- > > s.net> wrote: > > >> I created a file ./lib/action_view/helpers/asset_tag_helper.rb > > >> and put in it only the method I want to override. like this > > > Don''t. Create lib/my_module.rb and then include MyModule into > > ActionView::Base. Or it might be more convenient to do this in > > application_helper > > -- > Posted viahttp://www.ruby-forum.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, In our project we are using lib file as suggested file name would be: lib/action_view_ext.rb module ActionView module Helpers #:nodoc: module AssetTagHelper def image_path(source) compute_public_path(source, ''images'') end end end end the best way to include the file !always! (doesn''t matter if the application helper is loaded or not) is to add one line at the end of the config/environment.rb the line would be: require ''lib/action_view_ext.rb'' Cheers --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks a lot for the quick response! BTW the reason why I want to override a method is because I need to support images for different locale. for instance : logo_fr.gif (for french) logo_en.gif (for of course english) In my view I want something like : <% image_tag(''logo.gif'', :locale => cookies[:locale])%> any better way? Thanks again -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
> In my view I want something like : > > <% image_tag(''logo.gif'', :locale => cookies[:locale])%> > > any better way?Will all the pictures on the site be localized? Probably not - maybe it would be better if you create a method called something like image_localized_tag in your application helper. It could take "locale" from cookie and change passed file name (locale isn''t parameter now). After changing the name it could just call image_tag and return the result. This is just a suggestion - IMHO it''s easier to implement and cleaner later on for other developers - some of them may expect different behaviour from image_tag cheers --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
After rethinking of it that''s what I plan to do. Just wnat to make sure it is the right way and I wanted assements of experts. Thank you very much. -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---