Translating a routes.rb endpoint from 0.9.12 to 1.x

11 views
Skip to first unread message

Walter Lee Davis

unread,
Jun 27, 2015, 12:48:03 PM6/27/15
to dragonf...@googlegroups.com
I am upgrading a large application from Rails 3.0 to 4.2. This has necessitated a jump to the latest Dragonfly.

I am having some difficulty getting my head around the differences between 0.9 and 1.0. I have read the guide to migration, and am slowly getting most of the basics fixed, but I have the following routes defined that I use for my JS cropper:

get '/thumbs/:width-:height-:x-:y;:scale_x-:scale_y/:id-*more' => Dragonfly[:images].endpoint { |params, app|
#app.fetch(params[:uid]).thumb(Base64.decode64(params[:geometry]))
geometry = "#{params[:width].to_i(36)}x#{params[:height].to_i(36)}+#{params[:x].to_i(36)}+#{params[:y].to_i(36)}"
crop = "#{params[:scale_x].to_i(36)}x#{params[:scale_y].to_i(36)}"
Image.find(params[:id].to_s.split('-').first).file.thumb(geometry).convert("-resize #{crop}")
}
get '/thumbs/:width-:height-:x-:y/:id-*more' => Dragonfly[:images].endpoint { |params, app|
#app.fetch(params[:uid]).thumb(Base64.decode64(params[:geometry]))
geometry = "#{params[:width].to_i(36)}x#{params[:height].to_i(36)}+#{params[:x].to_i(36)}+#{params[:y].to_i(36)}"
Image.find(params[:id].to_s.split('-').first).file.thumb(geometry)
}

I need to support these URLs forever, because they are in the database (CMS) already. When I hit them, I am either getting some odd JSON decode errors or the entire application never makes it out of rack (no log in console from Rails).

The other difference I have seen between my legacy app and a simple test app I created is that all of the Dragonfly URLs seem to end in sha=asdfksdfd… and my existing URLs in the database do not have that. I have seen the `allow_legacy_urls true` configuration statement — is this enough to get around that, or is there any other way to make this optional?

Thanks in advance,

Walter

Frederick Cheung

unread,
Jun 27, 2015, 7:01:52 PM6/27/15
to dragonf...@googlegroups.com


> On 27 Jun 2015, at 17:47, Walter Lee Davis <wa...@wdstudio.com> wrote:
>
> I need to support these URLs forever, because they are in the database (CMS) already. When I hit them, I am either getting some odd JSON decode errors or the entire application never makes it out of rack (no log in console from Rails).
>
> The other difference I have seen between my legacy app and a simple test app I created is that all of the Dragonfly URLs seem to end in sha=asdfksdfd… and my existing URLs in the database do not have that. I have seen the `allow_legacy_urls true` configuration statement — is this enough to get around that, or is there any other way to make this optional?
>

The json errors make sense - the job definition used to be encoded using Marshal.dump but it is now dumped as json (and in both cases base64 encoded). The allow_legacy_urls setting controls whether dragonfly will try to fallback to marshal.load if json parsing fails.

The sha business is separate - it is a portion of a sha sum of the job definition and a secret you specify in the config - requests where the sha parameter doesn't match what is calculated are rejected. The setting controlling this is called something like protect_from_dos or something like that - I think the default changed from false to true in 1.0

There is also a document covering upgrading to 1.0 - either in the source or the GitHub wiki.

Fred
> Thanks in advance,
>
> Walter
>
> --
> You received this message because you are subscribed to the Google Groups "Dragonfly" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dragonfly-use...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages