No commit activity in last 3 years
No release in over 3 years
Papercli with bunch of extensions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.0
 Project Readme

Smarter Paperclip

Paperclip with some additional cool stuff. This Paperclip version uses old Paperclip but it is tweaked up to work with Rails 3.2.

Collection of Paperclip extensions:

  • validates_attachment_minimum_resolution
  • validates_attachment_if_included
  • has_interpolated_attached_file

Works with Ruby 1.8.7, 1.8.7 EE, 1.9.2, 1.9.3 Works with Rails3

Install

gem install smarter_paperclip

and in your Gemfile:

gem 'smarter_paperclip'

Usage

validates_attachment_minimum_resolution - Picture minimal resolution validation. Parameters:

  • width - minimal picture width
  • height - minimal picture height
  • message - error message - can be a Proc
  • other params - std like for other validations (like if, unless, etc)

validates_attachment_if_included - It force attachment validation only if attachment (file) was send. If file was not send - it will not validate it (will pass without errors)

has_interpolated_attached_file - Allows you to use interpolations embed to object instance without worrying about file renaming. It rename them for you. Just use it instead of has_attached_file. Parameters same as with has_attached_file.

Of course you can use it instead of has_attached_file all the time, because with standard (not interpolated) models - it works same as has_attached_file.

Example

Interpolation

Paperclip.interpolates :instance_name do |attachment, style|
	attachment.instance.name.to_url
end

Model

class Biography < ActiveRecord::Base
	has_interpolated_attached_file :photo,
	  :url => "/images/models/biographies/:id/:instance_name_:style.:extension"
	              
	validates_attachment_if_included :photo,

	validates_attachment_minimum_resolution :photo, :width => 500, :height => 500
end

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2011 Maciej Mensfeld. See LICENSE for details.