未知键:attributes, discard_if attachment_fu和回形针



嗨,我想为自己建立一个小画廊,并尝试了这个链接,为一个专辑的多个上传:http://www.mfischer.com/wordpress/2009/02/02/multiple-image-upload-and-crop-with-rails/

到目前为止,我遇到了以下错误,当我访问localhost:3000/albums/new:

ArgumentError in AlbumsController#index
Unknown key(s): attributes, discard_if

因为我不确定是否attachment_fu-Plugin和回曲针宝石(我使用)是正确使用,也许这是一个问题看了吗?

我的版本:

Ruby version    1.9.2 (x86_64-linux)
RubyGems version    1.7.1
Rack version    1.2
Rails version   3.0.4
Active Record version   3.0.4
Action Pack version 3.0.4
Active Resource version 3.0.4
Action Mailer version   3.0.4
Active Support version  3.0.4

不能告诉确切的attachment_fu版本…:/回形针版本如下:

paperclip (2.3.8)
My album model is this:
# == Schema Information
# Schema version: 20110404082122
#
# Table name: albums
#
#  id         :integer         not null, primary key
#  name       :string(255)
#  location   :string(255)
#  date       :date
#  created_at :datetime
#  updated_at :datetime
#
class Album < ActiveRecord::Base
  has_many  :images,
        :attributes => true,
        :discard_if => proc { |upload| upload.photo_file_size.nil? }
end

和我的图像模型是这样的:

# == Schema Information
# Schema version: 20110404082122
#
# Table name: images
#
#  id          :integer         not null, primary key
#  name        :string(255)
#  date        :date
#  landscape   :boolean
#  flash       :boolean
#  cameramaker :string(255)
#  cameramodel :string(255)
#  lens        :string(255)
#  flength     :string(255)
#  aperture    :string(255)
#  exposure    :string(255)
#  iso         :string(255)
#  album_id    :integer
#  filesize    :integer
#  created_at  :datetime
#  updated_at  :datetime
#
require 'RMagick'
class Image < ActiveRecord::Base
  belongs_to :album
  has_attached_file :photo,
            :styles => {
              :thumb => ["150x150", :jpg],
              :pagesize => ["500x400", :jpg],
            },
            :default_style => :pagesize
end

你还需要什么吗?我不明白是什么问题…我认为attachment_fu插件太老了,或者我错过了一些东西,说rails使用它…?

谢谢你的时间!

Wanye

http://apidock.com/rails/ActiveRecord/Associations/ClassMethods/has_many

has_many关联没有任何:attributes:discard_if选项

看起来像在教程作者使用attribute_fu插件。所以你需要安装它

https://github.com/jamesgolick/attribute_fu

相关内容

  • 没有找到相关文章

最新更新