This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Jonathan Conway (author)
Mon Apr 14 04:04:52 -0700 2008
| name | age | message | |
|---|---|---|---|
| |
History.txt | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
License.txt | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
Manifest.txt | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
README.txt | Mon Apr 14 04:04:52 -0700 2008 | [Jonathan Conway] |
| |
Rakefile | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
config/ | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
generators/ | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
lib/ | Mon Apr 14 04:04:52 -0700 2008 | [Jonathan Conway] |
| |
log/ | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
script/ | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
setup.rb | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
tasks/ | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
test/ | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
| |
website/ | Fri Apr 11 04:42:24 -0700 2008 | [Jonathan Conway] |
README.txt
I'm going through turning everything into a universal gem so that it can be used for both Rails and Merb.
This one is the Paperclip plugin from Thoughtbot.
To build the gem run 'rake package' then 'sudo gem install pkg/universal_paperclip-0.0.1.gem'
WARNING - DataMapper support is work in progress and does not yet work correctly. Please don't use it
unless you're helping getting it working. I need to extract how the validations are performed so that
they work with DM.
In Merb edit init.rb and add:
require 'paperclip'
#Choose one of the following.
Paperclip::Configure::enable_ar! # if you're using ActiveRecord or
# Paperclip::Configure::enable_dm! # if you're using DataMapper.
In Rails created a attachments.rb file in your initializers dir and add the line:
require 'paperclip'
#Choose one of the following.
Paperclip::Configure::enable_ar! # if you're using ActiveRecord or
# Paperclip::Configure::enable_dm! # if you're using DataMapper.
# Remember that if you're using Datamapper to define the attachment properties in your model
# unlike AR which you do in your migrations.
# e.g
# If you have something like:
#
# has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
#
# then you should define:
#
# property :avatar_file_name, :string
# property :avatar_content_type, :string
# property :avatar_file_size, :integer
Cheers
Jaikoo
=Paperclip
Paperclip is intended as an easy file attachment library for ActiveRecord. The intent behind it was to keep setup as
easy as possible and to treat files as much like other attributes as possible. This means they aren't saved to their
final locations on disk, nor are they deleted if set to nil, until ActiveRecord::Base#save is called. It manages
validations based on size and presence, if required. It can transform its assigned image into thumbnails if needed, and
the prerequisites are as simple as installing ImageMagick (which, for most modern Unix-based systems, is as easy as
installing the right packages). Attached files are saved to the filesystem and referenced in the browser by an easily
understandable specification, which has sensible and useful defaults.
See the documentation for the +has_attached_file+ method for options.
==Usage
In your model:
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end
In your edit and new views:
<% form_for :user, @user, :url => user_path, :html => { :multipart => true } do |form| %>
<%= form.file_field :avatar %>
<% end %>
In your controller:
def create
@user = User.create( params[:user] )
end
In your show view:
<%= image_tag @user.avatar.url %>
<%= image_tag @user.avatar.url(:medium) %>
<%= image_tag @user.avatar.url(:thumb) %>




