Ruby 手动更新Carrierwave上载程序装载的属性

Ruby 手动更新Carrierwave上载程序装载的属性,ruby,ruby-on-rails-3,activerecord,carrierwave,rails-activerecord,Ruby,Ruby On Rails 3,Activerecord,Carrierwave,Rails Activerecord,我无法对carrierwave上载程序装载的属性使用model.update_属性。SQL语句不接受该值,并将NULL添加到占位符中。如果我从模型类中删除mount_uploader语句,它将正常工作。我正在从控制台进行故障排除,并试图在植入DB时添加一些属性,这阻碍了我的工作。想法 谢谢 更新: 相关代码: class Profile < ActiveRecord::Base belongs_to :user has_and_belongs_to_many :sports h

我无法对carrierwave上载程序装载的属性使用model.update_属性。SQL语句不接受该值,并将NULL添加到占位符中。如果我从模型类中删除mount_uploader语句,它将正常工作。我正在从控制台进行故障排除,并试图在植入DB时添加一些属性,这阻碍了我的工作。想法

谢谢

更新: 相关代码:

class Profile < ActiveRecord::Base
  belongs_to :user
  has_and_belongs_to_many :sports
  has_and_belongs_to_many :interests
  has_and_belongs_to_many :minors
  has_and_belongs_to_many :majors
  has_and_belongs_to_many :events
  has_and_belongs_to_many :groups
  attr_accessible :description, :username, :avatar, :bio, :first_name, :last_name, :major, :minor, :graduation_date, :living_situation, :phone, :major_ids, :minor_ids, :sport_ids
  mount_uploader :avatar, AvatarUploader
end
类配置文件
我只是试图从db种子文件重写:avatar字符串,并在rails控制台上进行测试,如下所示: Profile.first.update_属性(:头像'foo')

当我注释掉mount_uploader行时,这两种方法都有效


添加mount\u uploader方法是否会冻结字符串或使其不可变?

我找到了解决方案

我的问题是,我无法更改从seeds.rb文件装载到CarrierWave上传程序的属性

这项工作:

user.profile.update_column(:avatar, 'foobar/image.png')

如果您发布您试图执行的代码,这将非常有用。您试图将属性设置为什么值?