Giter VIP home page Giter VIP logo

carrierwave-serializable's Introduction

Stand With Ukraine

Carrierwave::Serializable Build Status

Carrierwave plugin that allow mount uploader to serialized field

Installation

Add this line to your application's Gemfile:

gem 'carrierwave-serializable'

Or install it yourself as:

$ gem install carrierwave-serializable

Usage

To mount an uploader to the serialized field, set the serialize_to option to the serialized field where you want to store the uploader.

class User < ActiveRecord::Base
  serialize :documents, Hash
  mount_uploader :document1, DocumentUploader, serialize_to: :documents
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

carrierwave-serializable's People

Contributors

andrey-skat avatar benhutton avatar bkudria avatar krule avatar lsylvester avatar timfjord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

carrierwave-serializable's Issues

Carrierwave Serializable gem causing test failing right after installing it

Before including carrierwave-serializable gem in my Gem and installing it, my rails test passes.

After I include carrierwave-serializable gem in my Gem file then do a bundle install and lastly, a rails test, I get 8 test failures.

I did not even modify any other source file. How can my tests break all of a sudden?

Does carrierwave-serializable do some magic behind the scenes right after installing the gem with bundle install ?

I am worried it might conflict with some of my file naming or class naming.

I wrote a Stackoverflow question here: http://stackoverflow.com/questions/40890774/rails-installing-carrierwave-serializable-gem-causes-test-to-fail

I am using Active Model Serializer, Pundit, Knock and Carrierwave and Carrierwave Serializable gems.

My system is running Rails 5.0.0.1 and Ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

[Feature Request] Need a convenient method to get original field real value

Some times, I will import some image data from rake task, so, my mounted image
field will have a http://some_site/some_image.png value.

so,I will handle this situation with override uploader url method like this:

  def url
     # here, if not use a serialize field, model[mounted_as] will get the original value.
    original_url = model[mounted_as]

    original_url =~ %r{\Ahttps?://} ? original_url : super
  end

But if use serialize, model[mounted_as] or model.read_attribute[mounted_as is
not worked anymore,we need a new api to get the correct value.

currently, I have to do like this:

  def url
    serialize_to = model.class.serialized_uploaders[mounted_as]
    original_url = model[serialize_to][mounted_as.to_s]

    original_url =~ %r{\Ahttps?://} ? original_url : super

  end

Here, if can expose a original_url API, is good. Thanks.

[Doubt]

Hi everyone! Just me asking about an error.
I already properly install Carrierwave with multiple uploads, and now just trying to add serializable functionality for all those images.

My question is how should i define the hash in the whitelist parameters to accept a Hash variable.

Im getting the error: Attribute was supposed to be a Hash, but was a Array. -- []

The only place an array may appear (i think) its here:

def used_car_params
params.require(:used_car).permit(........, {pictures: []},
...
end

At least that works with simple multi uploads.

PD: Already did everything as explain before to configure, but looks like i miss something.
Thanks in advance.

Not worked with jsonb column in Rails 4.2.4, Thanks.

# schema.rb
    t.jsonb    "delivery_info",         default: {}
  # order.rb

  # add return_logistics_image accessor method.
  store_accessor :delivery_info, :return_logistics_image
  mount_uploader :return_logistics_image, ImageUploader, serialize_to: :delivery_info

When create a new order object, exist following error:

NoMethodError (undefined method `return_logistics_image_changed?' for #<Order:0x007f1af7c68338>):
  app/models/order_transition.rb:7:in `block in <class:OrderTransition>'
  app/models/order.rb:182:in `transition_to!'
  app/models/order/buyer_action.rb:10:in `accept'
  app/models/concerns/set_order_action_callback.rb:13:in `public_send'
  app/models/concerns/set_order_action_callback.rb:13:in `block (2 levels) in method_added'
  app/models/concerns/set_order_action_callback.rb:12:in `block in method_added'
  app/api/api/buyer_action.rb:26:in `accept'
  app/controllers/orders_controller.rb:33:in `action!'
  app/controllers/buyer_orders_controller.rb:131:in `action!'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.