Archive for June 22nd, 2006

Plugin: file_column

This is straight from the “file_column website”:http://www.kanthak.net/opensource/file_column/:

Just make the “image” column ready for handling uploaded files…

class Entry < ActiveRecord::Base
file_column :image
end

… generate file fields *that keep uploaded images during form redisplays to your view…

<%= file_column_field “entry”, “image” %>

… and display uploaded images in your view:

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

However, you may want to protect against the model object having no uploaded image:

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

To resize every uploaded image to a maximum size of 640×480, you just have to declare an additional option.

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

You can even automatically create versions in different sizes that have nice filenames…

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

… and display them in your view:

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

8 comments June 22, 2006


Important Notice…

I have moved this blog to http://webonrails.com . I will continue posting at http://webonrails.com, not on http://webonrails.wordpress.com.

Kindly update your book marks to http://webonrails.com

and http://webonrails.com/feed .

I am really very sorry for inconvenience.

Comming Soon….

Domain for Sale

TheRailsHosting.com


(Contact me)

c

Top Posts

Recent Posts

Recent Comments

jyoti on Ruby On Rails India
extessBob on My new HP Pavillion DV2117…
clexmases on My new HP Pavillion DV2117…
i can haz ajax? on Uploading files using AJA…
Peter on Plugin: NumbersToWords

rails

Ruby

RubyonRails

Calender

June 2006
M T W T F S S
« Apr   Jul »
 1234
567891011
12131415161718
19202122232425
2627282930  

Archives

Subscribe

  • Add to Google
  • Subscribe in NewsGator Online
  • Subscribe with Bloglines
  • WebOnRails on feedburner
  • technorati

del.icio.us

Feeds

Flickr Photos

iris

Icing on the Cake

* 7 EXPLORE

More Photos

Visitor’s Location

Spam Blocked

Blog Stats