我正在使用Paperclip插件管理文件上传到我的应用程序。出于某种原因,在最后一天左右,插件/模型已停止工作,现在返回以下错误消息:
Paperclip::PaperclipError in DeliversController#create
Asset model missing required attr_accessor for 'data_file_name'
据我所知,我没有触及传送控制器或回形针插件。
之前有没有人看过这个错误,或者知道如何追踪错误发送的文件的最后一次更改?
作为参考,db模式如下:
# Create Delivers Table
create_table :delivers do |t|
t.column :caseref, :string
t.column :casesubject, :string
t.column :description, :text
t.column :document_file_name, :string
t.column :document_content_type, :string
t.column :document_file_size, :integer
t.column :document_updated_at, :datetime
t.timestamps
end
# Create Assets Table
create_table :assets do |t|
t.column :attachable_id, :integer
t.column :attachable_type, :string
t.column :date_file_name, :string
t.column :date_content_type, :string
t.column :date_file_size, :integer
t.column :attachings_count, :integer, :default => 0
t.column :created_at, :datetime
t.column :date_updated_at, :datetime
t.timestamps
end
,资产模型如下:
class Asset < ActiveRecord::Base
has_attached_file :data,
:url => "/assets/:id",
:path => ":rails_root/assets/docs/:id/:style/:basename.:extension"
belongs_to :attachable, :polymorphic => true
def url(*args)
data.url(*args)
end
def name
data_file_name
end
def content_type
data_content_type
end
def file_size
data_file_size
end
end
谢谢,
丹尼
答案 0 :(得分:2)
# Create Assets Table
t.column :date_file_name, :string
^^^
class Asset < ActiveRecord::Base
has_attached_file :data,
^^^
看到区别?一旦它是datE而不是它的datA
答案 1 :(得分:1)
试着改变这个
#Create Assets Table
create_table :assets do |t|
t.column :attachable_id, :integer
t.column :attachable_type, :string
t.column :date_file_name, :string
t.column :date_content_type, :string
t.column :date_file_size, :integer
t.column :attachings_count, :integer, :default => 0
t.column :created_at, :datetime
t.column :date_updated_at, :datetime
t.timestamps
end
到这个
# Create Assets Table
create_table :assets do |t|
t.column :attachable_id, :integer
t.column :attachable_type, :string
t.column :data_file_name, :string
t.column :data_content_type, :string
t.column :data_file_size, :integer
t.column :attachings_count, :integer, :default => 0
t.column :created_at, :datetime
t.column :date_updated_at, :datetime
t.timestamps
end
我认为错误消息表明它是
缺少资产模型attr_accessor为'data_file_name'