Coder Social home page Coder Social logo

paperclip_database's Introduction

Paperclip Database Storage

Build Status Gem Version Dependency Status Code Climate

Paperclip Database Storage is an additional storage option for Paperclip. It gives you the opportunity to store your paperclip binary file uploads in the database along with all your other data.

Requirements

paperclip_database depends on paperclip

It is recommended to use the trim_blobs gem to limit the logging of BLOB data in your logfiles.

Installation

Paperclip Database Storage is distributed as a gem, which is how it should be used in your app.

Include the gem in your Gemfile:

gem "paperclip_database", "~> 2.0"

Or, if you want to get the latest, you can get master from the main paperclip repository:

gem "paperclip_database", :git => "git://github.com/softace/paperclip_database.git"

If you're trying to use features that don't seem to be in the latest released gem, but are mentioned in this README, then you probably need to specify the master branch if you want to use them. This README is probably ahead of the latest released version, if you're reading it on GitHub.

Supported Versions

As of version 2.0, Rails 2 is no longer supported. Supported version are rails >= 3.0 and paperclip version >= 2.3

Quick Start

There is no quick start. You definitely need to understand how to use paperclip first.

Usage

You use paperclip_database by specifying database as storage for your paperclip and create a migration for the additional database table.

In your model:

class User < ActiveRecord::Base
  has_attached_file :avatar,
                    :storage => :database ## This is the essence
                    :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

There is a migration generator that will create a basic migration for the extra table.

On the console (rails 3):

bundle exec ./script/rails generate paperclip_database:migration User avatar

The generated migration should be sufficient, but you may consider adding additional code to the migration such as t.timestamps for adding standard rails timesstamps or a referential database constraint, or an index on the foreign key id column. If you add a refferential constraint with the option ON DELETE CASCADE, then you need to add the option :cascade_deletion => true to your paperclip has_attached_file declaration to let PaperclipDatabase know that the Database takes care of it. Otherwise PaperclipDatabase will do the cascade deletion.

Development

To start develop, please download the source code

git clone git://github.com/softace/paperclip_database.git

When downloaded, you can start issuing the commands like

bundle install
bundle exec appraisal clean
bundle exec appraisal generate
bundle exec appraisal install
bundle exec appraisal rake

Or you can see what other options are there:

bundle exec rake -T

History

Paperclip Database Storage is heavily inspired by this blog by Pat Shaughnessy. The initial source code for that blog is no longer available, but the code in this gem is based on that initial code.

Copyright

Copyright (c) 2012 Jarl Friis. See LICENSE.txt for further details.

paperclip_database's People

Contributors

coryfoy avatar cpence avatar jarl-dk avatar jlebensold avatar juliancheal avatar pjungwir avatar plexus avatar pwnall avatar

Watchers

 avatar  avatar

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.