New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

paperclip-staging

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paperclip-staging

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Paperclip::Staging

Allow Paperclip to pass attachments as data-uri on unsaved records. Useful when dealing with forms and validation errors.

Imagine you have two fields on a model - name and attachment. Let's say that name has a validation. If you edit an object and change both name and attachment, but the new name doesn't meet the validation, then you lose the new attachment.

With paperclip-staging, the attachment is preserved using a hidden field. It is also available with staged_url(style_name) (instead of regular url(style_name)) calls, using data-uri encoding - which is useful if you want to display current value for the attachment/image.

You can check the example project.

Installation

Add this line to your application's Gemfile:

gem 'paperclip-staging'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paperclip-staging

Usage

  1. Add a new hidden field in the form, named <attachment_name>_staging.

    f.hidden_field :file_staging

    or

    f.input :file_staging, as: :hidden for simple_form

  2. Add this field as a valid form param:

    attr_accessible :file_staging

    or

    params.require(xxx).permit(xxx, :file_staging) for Rails 4

  3. That's it!

Contributing

  1. Fork it ( https://github.com/dabroz/paperclip-staging/fork )
  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 a new Pull Request

FAQs

Package last updated on 01 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc