I used the spree e-Commerce CMS for checking or R&D of Spree code. Spree is the really nice and basic tool for e-Commerce CMS.
When i was going through Spree i got to know about paperclip plugin which is used for image manipulation. Earlier i used “attachment_fu” for image manipulation and file uploading in rails projects.
How to use “Paperclip‘
First install perperclip plugin to your project.
Windows and Linux user can use my code. (I used this in WindowsXP and Fedora 9)
#ruby script /plugin install https://svn.thoughtbot.com/plugins/paperclip/trunk/
through this command perperclip get installed in your project folder.
Many time you need photo upload functionality for customer
Here i used Customer contoller and Customer model for this lession
First run following command
#ruby script/generate paperclip ModelName FieldName
In my case command is:
#ruby script/generate paperclip Customer customer_pic
One migration file will be created through this command. Run that migration.
In Customer model file paste this code:
class Customer < ActiveRecord::Base
# Paperclip
has_attached_file :customer_pic,
:styles => {
:thumb=> "100x100#",
:small => "150x150>" }
end
Using this command you will save three pic(photo) in your system folder.
Default upload url of peperclip is (RAILS_ROOT/public/system/…)
You can use following lines in your model file. (copy & paste this code under styles code)
:url => “/uploads/:class/:attachment/:id/:style_:basename.:extension”,
:path => “:rails_root/public/uploads/:class/:attachment/:id/:style_:basename.:extension”
I added uploads folder front on :class. That is optional you can remove also.
If you are already having forms for customer and if you want to add that to form. Just use this code in your form tag.
:html => { :multipart => true
and in from <%= f.file_field :customer_pic%>
That sit. you need to add or use following code in View
<%= image_tag @user.customer_pic.url %>
<%= image_tag @user.customer_pic.url(:thumb) %>
Paperclip Validations
Here i giving some validation for Paperclip. You need to just copy & paste in to your model where you want to use image upload.
validates_attachment_content_type :avatar, :content_type => 'image/jpeg'
validates_attachment_presence :avatar
I found this plugin is very usefull for Me. It really saves lots of time.
Incoming search terms:
- attachment fu upload large files continue
- paperclip copy image into folder
- paperclip plugin wordpress
- rails image upload manipulation
- wordpress api upload
- wordpress attachment_fu






Pingback: uberVU - social comments
Super stuff! This was a really effective publish.
I would like to say “wow” what a inspiring post. This is really great. Keep doing what you’re doing!!
Of course, what a great site and informative posts, I will add backlink – bookmark this site? Regards, Reader
Thanks for posting. Good to see that not everyone is using RSS feeds to build their blogs
Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.