好的,所以我有这个模型...
class Asset < ActiveRecord::Base
attr_accessible :asset_file_name, :lesson_id, :attachment
has_attached_file :attachment,
:url => "/attachments/:id/:basename.:extension",
:path => ":rails_root/public/attachments/:id/:basename.:extension"
validates_presence_of :asset_file_name
validates_attachment_presence :attachment
end
(也有一个模型Lesson
)
我想将附件保存到/attachments/:lesson_id/:basename.:extension
. 这不是:id
资产的,而是 :lesson_id。当我这样做时,目录实际上只是命名为:lesson_id
. 有人知道如何获得实际的lesson_id
吗?我也试过了@asset.lesson_id
。