-
Notifications
You must be signed in to change notification settings - Fork 142
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
Make FileFilter check more generic so ActionDispatch::Http::UploadedFile is accepted #236
Conversation
We considered supporting any IO before. Check out issue #67. This might be a good motivation to do that. I have not heard of CarrierWave before. Since it's a gem that we don't claim to support, I would argue that this isn't a bug per se. |
Well, it's quite popular: it seconds |
Well, |
Oh, I didn't realize that method was so new. I figured that it's been around since Ruby 1.8.6 at least, so any IO-ish object would probably implement it. Looks like I was wrong. This pull request is effectively making the file filter a shortcut for the interface filter with some methods preset. It might be better to implement it that way. |
b1cb20d
to
025c21b
Compare
Hi, reimplemented |
super | ||
end | ||
def methods | ||
super + [:close] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should not call super
. If it does, you could do this:
file :whatever,
methods: [:foobar]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
Thank you! I think it looks a lot better. We should see what @AaronLasseigne thinks. |
I'm a little concerned about using Also, thanks @conf for the PR! |
I should also note that we originally pulled the tempfile so that you were guaranteed an object that responded to all the |
025c21b
to
4e9a7be
Compare
@AaronLasseigne Ok, changed check to |
4e9a7be
to
11dcaff
Compare
👍 This is a breaking change to that API we provide for file inputs, so it'll have to be part of v2.0.0. |
So, when this is going to be merged? Should I rebase it against some other branch or smth? |
Yes, could you please open a new pull request against the v2.0.0 branch? |
Sure: #243 |
Hello!
I stumbled with this bug when I tried to use
active_interaction
andCarrierWave
together. The bug consists in the following:Since
actionpack
'sActionDispatch::Http::UploadedFile
responds totempfle
,CarrierWave
(insideActiveRecord
model) receivesTempfile
instance and not its wrapperActionDispatch::Http::UploadedFile
, losing this way access to extra variables likeoriginal_file_name
,content_type
and etc. This breaks someCarrierwave
validations and ends up with saving file with a generic temporary name likerack20141203-27678-2wbop
without extension which is not good.So I made this check more generic according the fact that all
IO
-like classes respond toclose
method.I couldn't write more explicit specs to test this behavior without adding
CarrierWave
oractionpack
as a dependency. If you're not satisfied with changes in this pull request, I'll be happy to work on it together.Cheers!