Re: [Rails-core] #asset_url helper method

266 views
Skip to first unread message

Rafael Mendonça França

unread,
Oct 19, 2012, 9:29:10 AM10/19/12
to rubyonra...@googlegroups.com
I think this is how all the assets helpers work by default.

https://github.com/rails/rails/blob/e826a5c749f9a4029a3b2a7e3d371498feeb9b10/actionpack/lib/action_view/asset_paths.rb#L108

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca



On Thu, Oct 18, 2012 at 8:44 PM, Scott Carleton <carleto...@gmail.com> wrote:
Just putting this out there before I make a pull request.

Is there any interest in an asset_url method as a view helper?

It would work by using the config.action_controller.asset_host if it exists and prepending this to the results of asset_path.

I have found this necessary when writing html emails and needing a full url path for assets.  Since my CDN in the asset_host mirrors my assets in my app it makes perfect sense.  Might not be a common enough use case to put into core though.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/itwdyjwfSJIJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.

Scott Carleton

unread,
Oct 29, 2012, 3:24:29 PM10/29/12
to rubyonra...@googlegroups.com
I haven't had time to test but you're saying the asset_path helper will provide the full url by default?  

In console within production environment it seems to only return the path which isn't sufficient for html emails.

Andrés Mejía

unread,
Oct 30, 2012, 12:58:53 AM10/30/12
to rubyonra...@googlegroups.com
If I remember correctly, asset_path will return the full URL if you set

config.action_mailer.asset_host = "http://my.assets.com"

in your environment file.

To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/eXzbI8y1Cg0J.
Reply all
Reply to author
Forward
0 new messages