Giter Club home page Giter Club logo

paperclip_with_hobo's Introduction

Paperclip with Hobo

Install this plugin alongside paperclip.

It adds two small things:

  • Automatically declares the fields for you, so you can just add

     has_attached_file :photo
    

    to your model, and then run the migration generator. All options are automatically passed on to paperclip's has_attached_file.

  • Declares an input field

     <def tag="input" for="Paperclip::Attachment">
       <%= file_field_tag param_name_for_this, attributes %>
     </def>
    

    (to get this, you need <include src="paperclip" plugin="paperclip_with_hobo"/> in application.dryml)

Installation

Paperclip's official repository (https://github.com/thoughtbot/paperclip.git) has a bug (at the time of writing) that makes paperclip with hobo crash (see http://groups.google.com/group/hobousers/browse_thread/thread/752e154ff9725486).

But we can use a fork which is nicely patched. Add this to your Gemfile:

gem 'paperclip', :git => "git://github.com/jeanmartin/paperclip.git", :branch => "master"

Update your bundle:

bundle

Install paperclip_with_hobo:

rails plugin install git://github.com/tablatom/paperclip_with_hobo.git

Include the paperclip_with-hobo taglib in your application.dryml

<include src="paperclip" plugin="paperclip_with_hobo"/>

Add paperclip to one of your models:

has_attached_file :photo

Your default form for the model will now include the four attributes added by has_attached_file. To actually allow uploading, you will need to manually add the attachment field (photo in the above example) to your form, and don't forget to add the multipart attribute:

<extend tag="form" for="MyModel">
  <old-form merge multipart>
    <field-list: fields="photo, other-fields, ..."/>
  </old-form>
</extend>

Important Note

The name of the plugin is important. It doesn't have to be paperclip_with_hobo but it will only work if this plugin loads after paperclip itself. Calling it paperclip_something is a good way to ensure that.

paperclip_with_hobo's People

Contributors

bryanlarsen avatar gertthiel avatar iox avatar tslocke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

paperclip_with_hobo's Issues

Unable to generate hash without :hash_secret

I'm using Hobo_with_paperclip for a MySQL backend project on a machine running Windows... I followed the tutorial mentioned in the README word for word.

My model is named 'Contact'

However, when I try to add a new Contact, I get the following error:
"Unable to generate hash without :hash_secret"

http://brizzly.com/pic/4DUA

I have no idea why this is happening!

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.