Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest 3.1.1.rc1 uses /images/ instead of /assets/ for image_tag helper #3126

Closed
avocade opened this issue Sep 25, 2011 · 9 comments
Closed
Assignees
Milestone

Comments

@avocade
Copy link

avocade commented Sep 25, 2011

Verified by going back to 3.1.0, not changing any other gems or any code.

Using this in my Gemfile, last pulled today 5.minutes.ago:
gem 'rails', :git => 'git://github.com/rails/rails.git', :branch=>'3-1-stable'

Using this image_tag:
<%= image_tag 'fortythree-logo-small.png' %>

@spastorino
Copy link
Contributor

You should use asset_tag if you want to access /assets/* files.
3.1.0 referring to /assets/* was a bug, look at this https://github.com/rails/rails/blob/3-1-stable/actionpack/lib/action_view/helpers/asset_tag_helper.rb#L342-343 is documented that image_tag refers to /images/* files and is for backward compatibility.

@avocade
Copy link
Author

avocade commented Sep 25, 2011

So it's <%= asset_tag 'fortythree-logo-small.png', 'images' %> from now on, then? Feels a bit less DRY if you ask me, but perhaps that's the trade-off for backwards compatibility.

@spastorino
Copy link
Contributor

Actually there's definitely a bug in 3.1.1 related to this, let me review it a bit more and I will get back to you again

@spastorino spastorino reopened this Sep 25, 2011
@ghost ghost assigned tenderlove and spastorino Sep 25, 2011
@avocade
Copy link
Author

avocade commented Sep 25, 2011

Absolutely.

PS. Same bug if I'm using the image-url('file.png') in a scss or sass file, probably related. Renders url(/images/file.png) as well.

@feroult
Copy link

feroult commented Sep 26, 2011

Hi, maybe I am only making noise here, but as far as I can remember, image_tag hasn't changed it's behavior after the asset pipeline release.

I've tried 3.1.0.rc4, 3.1.1.rc1 and branch 3-1-stable (right now). All returned /images/ from image_tag helper.

Sorry if I am missing something.

@avocade
Copy link
Author

avocade commented Sep 26, 2011

In 3.1.0 (final) image_tag used /assets/image.png if I turned on the asset pipeline, as I would expect. My images just continued loading fine.

In the latest 3.1.1rc1 (pulled 5 mins ago), the image_tag still now returns /images/image.png, which is the old behavior. There has either been a policy change here or a bug.

(If it's a policy change I don't quite like it; using image_tag to get /assets is the most logical way it should work, if we asked specifically to have the asset pipeline turned on.)

@avocade
Copy link
Author

avocade commented Sep 26, 2011

Fantastic, works fine now. Still sass-rails gives /images/image.png when using the image-url helper, I've commented more lengthily over there.

Thanks Santiago!

@sush
Copy link

sush commented Sep 28, 2011

I don't know if it's related but sass-rails helpers have the same issue (rails/sass-rails#57), image-url produces url(/images/) instead of url(/assets/)

@tetherit
Copy link

I'm using latest stable rails 3.1.3 and image-url("icons/spinner.gif") generated /images/icons/spinner.gif instead of /assets/icons/spinner.gif -- what gives?

EDIT: I was missing require "sprockets/railtie" in my application.rb - adding it fixed the problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants