RMagick and file-column for windows
1. Download RMagick For Win
2. Unzip the file to local folder.
#gem install rmagick --local
3. Install file-column as plugin
#ruby script/plugin install http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk
Code 1:
class Entry < ActiveRecord::Base 'image'是entry这个表的一个字段,储存文件的路径。 上载 : 显示: _form.html: show.html:
file_column :image, :magick => {
:versions => { "thumb" => "50x50", "medium" => "640x480>" }
}
end
<%= image_tag url_for_file_column 'entry', 'image' ,'thumb'%>
<%= image_tag url_for_file_column 'entry', 'image' ,'medium'%>
<%= file_column_field 'entry', 'image' %>p>
<%= start_form_tag 'create',:multipart => true%>
<%= render :partial => 'form' %>
<%= submit_tag "Create" %>
<%= end_form_tag %>
"thumb" => "50x50" : 表示默认宽度50,高度自适应
"thumb" => "50x50!" : "!"表示强制50*50
"thumb" => "50x50>" : ">"表示如果图片本来就小,就不用放大
file_column :image, :store_dir=>"你想要存图片的目录"







评论排行榜