uha*_*doh 10 interpolation paperclip ruby-on-rails-3
我一直在制作定制插值的麻烦,经历了我在网上找到的每一个例子,但不管我做了什么,都没有成功.目前我有这个:
模型
has_attached_file :photo,
:path => ":rails_root/public/images/:img_name-:style.:extension",
:styles => {
:original => '100x100',
:thumb => '30x30'
}
Run Code Online (Sandbox Code Playgroud)
初始化/ paperclip.rb
Paperclip.interpolates :img_name do |attachment, style|
attachment.instance.img_name
end
Run Code Online (Sandbox Code Playgroud)
img_name在上传时使用图像填充表单.我上传的错误是:
参数无效 - (C:/ Users /.../ stream20110410-384-stl2lk20110230-213-1fm2bab,C:/.../ photo_upload/public/images /:img_name-original.jpg)
Jak*_*mpl 10
如果它直接在模型中似乎工作:
class Model < ActiveRecord::Base
Paperclip.interpolates :img_name do |attachment, style|
attachment.instance.img_name
end
has_attached_file :photo,
:path => ":rails_root/public/images/:img_name-:style.:extension",
:styles => {
:original => '100x100',
:thumb => '30x30'
}
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2853 次 |
| 最近记录: |