Skip to content

No warning when styles defined, but no :style parameter in custom path #940

Closed
justusromijn opened this Issue Jun 28, 2012 · 3 comments

4 participants

@justusromijn

I think it would be helpful to add some kind of warning when someone defines multiple styles, but also has a custom path where the style is not embedded.

has_attached_file :picture,
                      :path => ":rails_root/public/uploads/employee/:id/:filename",
                      :url => "/uploads/employee/:id/:filename",
                      :styles => { :web => "165x200"}

This fails silently, and it took me quite some time to figure out why my styles didn't work.

has_attached_file :picture,
                      :path => ":rails_root/public/uploads/employee/:id/:filename_:style",
                      :url => "/uploads/employee/:id/:filename_:style",
                      :styles => { :web => "165x200"}

This was the simple yet hard to see solution.

@jyurek
thoughtbot, inc. member
jyurek commented Jun 29, 2012

That's a good point! It would be awesome if you could submit a pull request for this.

@jayroh jayroh pushed a commit that referenced this issue Jun 29, 2012
Joel Oliveira [#940] Raise error when style defined & not in path
* Add StyleTokenNotFound in Errors
* Adjust tests to make sure :style present where not currently defined
d01b07c
@jayroh
jayroh commented Jun 30, 2012

@justusromijn I'm curious if the branch I just pushed would have helped you track that issue down earlier. If you want to revert your code to the original issue and use this branch, throw this in your Gemfile:

gem 'paperclip', git: 'git://github.com/thoughtbot/paperclip.git', branch: '940-warn-without-style-param-in-path'
@jayroh jayroh pushed a commit that referenced this issue Jul 4, 2012
Joel Oliveira [#940] Raise error when style defined & not in path
* Add StyleTokenNotFound in Errors
* Adjust tests to make sure :style present where not currently defined
a5d6189
@jayroh jayroh pushed a commit that referenced this issue Jul 4, 2012
Joel Oliveira [#940] Raise error when style defined & not in path
* Add StyleTokenNotFound in Errors
* Adjust tests to make sure :style present where not currently defined
b7b2b84
@sikachu
thoughtbot, inc. member
sikachu commented Jul 5, 2012

This has been fixed in #943

@sikachu sikachu closed this Jul 5, 2012
@sikachu sikachu added a commit that referenced this issue Jul 21, 2012
@sikachu sikachu Revert "[#940] Raise error when style defined & not in path"
Reverting this for now. This commit would better be in a minor release,
since it break everyone's application. Going to reopen the ticket and
mark it to be merged in next minor release.

This reverts commit b7b2b84.
a1281be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.