0

嘿,所以我有一个名为 Asset 的类,每个 Asset 都有一个:附件。我想获取上传文件的 :basename.:extension 并将其存储在 :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
4

1 回答 1

0

不知道为什么你想要一个asset_file_name 属性

但你应该能够通过attachment_file_name

于 2012-07-16T11:32:58.130 回答