File column plugin

Plugin details

This library makes handling of uploaded files in Ruby on Rails as easy as it should be. It helps you to not repeat yourself and write the same file handling code all over the place while providing you with nice features like keeping uploads during form redisplays, nice looking URLs for your uploaded files and easy integration with RMagick to resize uploaded images and create thumb-nails. Files are stored in the filesystem and the filename in the database.

Websitehttp://www.kanthak.net/opensource/file_column/ Repositoryhttp://opensvn.csie.org/rails_file_column/plugins/file_column/trunk/ Author Sebastian Kanthak Tags ImageUpload LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk/

In your model make your image column use the plugin

class User < ActiveRecord::Base
    file_column :picture



Include the correct form field in your view

<%= file_column_field "user", "picture" %>



Display the image in your views

<%= image_tag url_for_file_column("user", "picture") %>



File column also allows you to use rmagick easily to complete different tasks on a uploaded image.

Resize image:

file_column :picture, :magick => { 
          :versions => { "small" => "100x140", 
                         "middle" => "150x220", 
                         "portfolio" => "190x400",
                         :square => {:crop => "1:1", :size => "50x50", :name => "square"} }
        }



Check image type:

validates_file_format_of  :picture, :in => ["gif", "png", "jpg"]



Check image size:

validates_filesize_of     :picture, :in => 0..2.megabyte

Further Documentation

Edit plugin | Back in time (1 older version) | Last edited by: scott, about 1 year ago