Daniel Lopes
2009-Sep-12 00:53 UTC
compute_public_path should be public instead of private
Hello, I''m in the middle of a situation where the method compute_public_path must be public instead of private. Some times we need to add .mov, .flv or even another kind of asset like swf and I want use my correct public path because I already setup a exclusive host for my static assets (wich is the right behavior). I know I can use private methods inside my views, but it doesn''t sounds strange? Why we have methods like image_path and javascript_path (and are all public) but don''t have a method for all other kind of static assets?
Is it possible for you to do something like this: def explicitly_compute_public_path(source, dir, ext = nil, include_host = true) send(:compute_public_path, source, dir, ext, include_host) end --or-- module ActionView module Helpers module AssetTagHelper def explicitly_compute_public_path(source, dir, ext = nil, include_host = true) compute_public_path(source, dir, ext, include_host) end end end end WDYT? On Sep 11, 2009, at 5:53 PM, Daniel Lopes wrote:> > Hello, I''m in the middle of a situation where the method > compute_public_path must be public instead of private. > > Some times we need to add .mov, .flv or even another kind of asset > like swf and I want use my correct public path because I already setup > a exclusive host for my static assets (wich is the right behavior). > > I know I can use private methods inside my views, but it doesn''t > sounds strange? Why we have methods like image_path and > javascript_path (and are all public) but don''t have a method for all > other kind of static assets?
Daniel Lopes
2009-Sep-13 01:00 UTC
Re: compute_public_path should be public instead of private
I know I can open or access private methods in runtime, but you doesn''t think this method is a good thing to be public? On Sep 11, 11:21 pm, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is it possible for you to do something like this: > > def explicitly_compute_public_path(source, dir, ext = nil, > include_host = true) > send(:compute_public_path, source, dir, ext, include_host) > end > > --or-- > > module ActionView > module Helpers > module AssetTagHelper > def explicitly_compute_public_path(source, dir, ext = nil, > include_host = true) > compute_public_path(source, dir, ext, include_host) > end > end > end > end > > WDYT? > > On Sep 11, 2009, at 5:53 PM, Daniel Lopes wrote: > > > > > > > Hello, I''m in the middle of a situation where the method > > compute_public_path must be public instead of private. > > > Some times we need to add .mov, .flv or even another kind of asset > > like swf and I want use my correct public path because I already setup > > a exclusive host for my static assets (wich is the right behavior). > > > I know I can use private methods inside my views, but it doesn''t > > sounds strange? Why we have methods like image_path and > > javascript_path (and are all public) but don''t have a method for all > > other kind of static assets?
On Sep 12, 2009, at 6:00 PM, Daniel Lopes wrote:> > I know I can open or access private methods in runtime, but you > doesn''t think this method is a good thing to be public?I''ve personally never understood the rationale for making this method private. I''ve had to use it for custom asset-managers in the past and it being private leads to this kind of code. Maybe someone else understands the rationale because the use case for making it public is the existence of assets that were not anticipated in the framework.> On Sep 11, 11:21 pm, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Is it possible for you to do something like this: >> >> def explicitly_compute_public_path(source, dir, ext = nil, >> include_host = true) >> send(:compute_public_path, source, dir, ext, include_host) >> end >> >> --or-- >> >> module ActionView >> module Helpers >> module AssetTagHelper >> def explicitly_compute_public_path(source, dir, ext = nil, >> include_host = true) >> compute_public_path(source, dir, ext, include_host) >> end >> end >> end >> end >> >> WDYT? >> >> On Sep 11, 2009, at 5:53 PM, Daniel Lopes wrote: >> >> >> >> >> >>> Hello, I''m in the middle of a situation where the method >>> compute_public_path must be public instead of private. >> >>> Some times we need to add .mov, .flv or even another kind of asset >>> like swf and I want use my correct public path because I already >>> setup >>> a exclusive host for my static assets (wich is the right behavior). >> >>> I know I can use private methods inside my views, but it doesn''t >>> sounds strange? Why we have methods like image_path and >>> javascript_path (and are all public) but don''t have a method for all >>> other kind of static assets? > >