我正在使用名为 Photo 的模型,该模型引用了 Uploader 类..
class Photo < ActiveRecord::Base
attr_accessible :title, :album_id
belongs_to :album
mount_uploader :photo_image, PhotosUploader
end
class Album < ActiveRecord::Base
attr_accessible :title, :autor, :photos_attributes
has_many :photos, :dependent => :destroy
accepts_nested_attributes_for :photos
end
但是..当我尝试用图像保存新相册(或编辑,等等..)时,它不会保存文件(列 photo_image 保存为 NULL,文件也不会存储。
... views/albums/_form.html.erb
<%= f.fields_for :photos do |f| %>
<div class="field">
<%= f.label :photo_image %><br />
<%= f.file_field :photo_image %>
</div>
<% end %>
有什么建议吗?
最佳答案
只需尝试将 :photo_image
添加到 Photo 模型的 attr_accessible
中,它可能会对您有所帮助。
同时检查你的log/development.log
关于ruby-on-rails - CarrierWave 在文件列中保存 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9134339/