File Column Plugin in Rails

This is another plugin which i have implemented for File uploading. The main advantage of this is that we can integrate RMagick to it easily for generating thumbnails and giving other properties to the plugin.

The main thing after downloading the plugin from http://www.kanthak.net/opensource/file_column/file-column-0.3.1.tar.gz
you just need to put 2-3 lines of code and get things going

on the page from where u want to upload a file just write 1 line of code

    <%= file_column_field "entry", "image" %>

and on the page where you want to display that file write the following line

<%= image_tag url_for_file_column(“entry”, “image”) %>

You can use RMagick and make thumbnails of your image by adding the following line in the model

class Entry < ActiveRecord::Base
file_column :image, :magick => {
:versions => { “thumb” => “50×50”, “medium” => “640×480>” }
}
end

or

class Entry < ActiveRecord::Base
file_column :image, :magick => { :geometry => “640×480>” }
end

write this in the model of the page where u want to implement the plugin

Thats it.. njoi


UPDATES

The old version of file column plugin doesnt work in rails 2.2 …to get working in rails 2.2 then you need to modify file_coulmn.rb file.

Update the line #619 in vendor/plugins/file_column/lib/file_column.rb from

Inflector.underscore(self.name).to_s,
to
ActiveSupport::Inflector.underscore(self.name).to_s,

Or you can download the latest plugin from the github.com: http://github.com/rust/file_column/

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *