0

我正在使用carrierwave gem(版本0.8.0)。当我制作“rake db:migrate”时,我看到了奇怪的错误:



    ==  AddAttachmentLogoToMerchants: migrating ===================================
    -- change_table(:merchants)
    rake aborted!
    An error has occurred, this and all later migrations canceled:

    undefined method `attachment' for     ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::Table:0x007f900e6bde88

我的迁移:




      def self.up
        change_table :merchants  do |t|
          t.attachment :logo
        end
        remove_column :merchants, :logo_filename
      end

      def self.down
        add_column :merchants, :logo_filename, :string
        drop_attached_file :merchants, :logo
      end


我该如何解决?

4

1 回答 1

0

AFAIK int.attachment attachment应该是一种数据类型

change_table :merchants  do |t|
  t.attachment :logo
end

单击此处查找 postgresql 的数据类型列表如果您想要字符串以下应该工作

change_table :merchants  do |t|
  t.string :logo
end
于 2013-04-24T13:26:27.403 回答