嘿所以我有一个名为Asset的类,每个Asset都有一个:附件。我想采用:basename。:上传文件的扩展名并将其存储在:asset_file_name中。我该怎么做呢?这是我的班级:
class Asset < ActiveRecord::Base
attr_accessible :asset_file_name, :lesson_id, :attachment
#allows us to use :lesson_id in :url
Paperclip.interpolates :lesson_id do |attachment, style|
attachment.instance.lesson_id
end
has_attached_file :attachment,
:url => "/attachments/:lesson_id/:basename.:extension",
:path => ":rails_root/public/attachments/:lesson_id/:basename.:extension"
validates_presence_of :asset_file_name
validates_attachment_presence :attachment
end
答案 0 :(得分:0)
不确定为什么要拥有asset_file_name属性
但你应该能够通过attachment_file_name