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

Breaking change on master #39

Closed
hakunin opened this issue Feb 2, 2016 · 2 comments
Closed

Breaking change on master #39

hakunin opened this issue Feb 2, 2016 · 2 comments

Comments

@hakunin
Copy link

hakunin commented Feb 2, 2016

This used to work

    @upload = Upload.create!(resource_params)

With attributes passed being

{
 #...
 "attachment"=>
  {"id"=>
    "2162ef5ccc922cf071e81504c5cf08e60d135e7144887cb0565eb85ba021/Screen Shot 2016-01-25 at 15.16.39.png",
   "storage"=>"cache",
   "metadata"=>
    {"width"=>342,
     "height"=>348,
     "size"=>73681,
     "filename"=>"Screen Shot 2016-01-25 at 15.16.39.png",
     "mime_type"=>"image/png"}},
 }

Now I get

Shrine::Error: unknown version: "id"`
from: /Users/michal/.rvm/gems/ruby-2.2.1/bundler/gems/shrine-01f20b64ef4a/lib/shrine/plugins/versions.rb" line 105 in block in versions!

If I go back to earlier revision 3ab14cb1ad71e1254b025bf4ae721c3fed52a16f the code works.

@janko
Copy link
Member

janko commented Feb 2, 2016

Yes, this was actually one of the documented breaking changes that version 1.0.0 introduced (the mentioned commit was prior to version 1.0.0). Prior to that version, cached files could be accepted as a hash or a JSON string. However, I didn't consider that essential functionality, and it was introducing problems when I was trying to write a plugin for multiple file uploads, so I extracted it out into a plugin for easier maintenance.

To get the old behaviour, just do Shrine.plugin :parsed_json in your initializer. Alternatively you could just send the cached file data as a JSON string instead of a hash.

@janko janko closed this as completed Feb 2, 2016
@hakunin
Copy link
Author

hakunin commented Feb 2, 2016

Thanks!

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

2 participants