I'm kind of in need this functionality but in the gem. Any tips on a
roundabout way of achieving this? Like the OP I have a situation
where the user might not necessarily upload an image, and only images
need to be thumbnailed. Any alternative way to ignore versions based
on conditions?
On Jul 20, 3:41 pm, Jonas Nicklas <
jonas.nick...@gmail.com> wrote:
> I know this is from ages ago, but this is the first time I've had time
> to work on CarrierWave since forever. I tried out your branch and
> fixed it up a little bit. See here:
>
>
http://github.com/jnicklas/carrierwave/commits/version_fix
>
> But now there's some strange behaviour. I haven't added the version
> check to retrieve_from_cache or retrieve_from_store, because of that
> it might behave quite odd when actually used. The problem is that when
> we're not using the File storage, that file we're checking again might
> not be a CarrierWave::SanitizedFile and then it becomes very hard to
> reason about how the whole thing works. Since we can't store which
> versions were actually created, there is no way to check afterwards if
> they were.
>
> We'd need some much better integration tests for this, imho. I'm very
> hesitant about merging this without that.
>
> /Jonas
>
> On Fri, May 21, 2010 at 6:35 PM, Ian Warshak <
iwars...@stripey.net> wrote:
> > What do you think that would take to implement?
> > My idea is to re-implement #version which would store the block as well as
> > the name of the "conditional method" to call. The block would then be
> > evaluated if it passes the conditional method when the object is
> > stored/pulled from the cache/storage,
> > So maybe something like this:
https://gist.github.com/866520f2a85c4ccf7e26
> > (not sure if that code actually works, just an idea)
> > What do you think about that approach?
> > Ian
>
> > On Sun, May 9, 2010 at 9:14 AM, Jonas Nicklas <
jonas.nick...@gmail.com>
> > wrote:
>
> >> I don't see how adding your own conditions is made easier with
> >> lambdas? Can you give an example?
>
> >> I think we are miusunderstanding each other, in my example bar? is an
> >> *instance* method, I think you can achieve pretty much anything you
> >> want with that callback syntax as with the lambda syntax. And I just
> >> find lambdas ugly ;)
>
> >> /Jonas
>
> >> On Thu, May 6, 2010 at 6:52 PM, Ian Warshak <
iwars...@gmail.com> wrote:
> >> > What's wrong with using lambdas? By using a lambda in this case, it
> >> > makes it
> >> > much easier for someone to add their own conditions.
> >> > My other thought would be that the block that is passed into version
> >> > could
> >> > be stored, then evaluated at a later time instead of immediately being
> >> > evaluated immediately. For instance when the cache is set or when an
> >> > object
> >> > is pulled from storage. This way we can have the method :bar be an
> >> > instance
> >> > method on the uploader instead of being a class method or even a lambda.
> >> > Ian
>
> >> > On Wed, May 5, 2010 at 5:16 PM, Jonas Nicklas <
jonas.nick...@gmail.com>
> >> > wrote:
>
> >> >> I dislike the use of lambdas, I'd prefer a callback, as in:
>
> >> >> version :foo, :if => :bar? do
>
> >> >> end
>
> >> >> def bar?
>
> >> >> end
>
> >> >> this would mean we can add the image? method to the rmagick module
> >> >> already, and have the (probably by far) most common use case covered
> >> >> with nice syntax. Plus, I just don't like lambdas as an API ;)
>
> >> >> /Jonas
>
> >> >> On Wed, May 5, 2010 at 5:52 PM, Ian Warshak <
iwars...@gmail.com> wrote:
> >> >> > I spent a few hours hacking on this and here is what I came up with
> >> >> > and
> >> >> > it
> >> >> > works for what I am using it for:
>
> >> >> >
http://github.com/iwarshak/carrierwave/commit/47a1ed8890bbf3064a8399e...
> >> >> > If there is a better approach, or you see something that can be done
> >> >> > better
> >> >> > let me know. I'd appreciate any feedback. I hope that this feature
> >> >> > can
> >> >> > get
> >> >> > added to CarrierWave because I can see a lot of use cases for it.
> >> >> > Ian
>
> >> >> > On Tue, May 4, 2010 at 3:20 PM, Jonas Nicklas
> >> >> > <
jonas.nick...@gmail.com>
> >> >> > wrote:
>
> >> >> >> There's a recent thread about this, with a nice proposed solution.
> >> >> >> Haven't gotten around to implementing it yet though, and haven't
> >> >> >> received a patch.
>
> >> >> >> /Jonas
>
> >> >> >> On Tue, May 4, 2010 at 7:24 PM,
iwars...@stripey.net
> >> >> >> <
iwars...@gmail.com>