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
          file_column :image, :magick => {    
                      :versions => { "thumb" => "50x50""medium" => "640x480>" }   
          }
end

'image'是entry这个表的一个字段,储存文件的路径。

上载 :

显示:
<%= image_tag url_for_file_column 'entry', 'image' ,'thumb'%> 
 <%= image_tag url_for_file_column 'entry', 'image' ,'medium'%>  

_form.html:
<%= file_column_field 'entry', 'image'  %>p> 

show.html:
<%= 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=>"你想要存图片的目录"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值