CarrierWave在文件列中保存NULL [英] CarrierWave save NULL at file column
本文介绍了CarrierWave在文件列中保存NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用称为上载类的Photo模型。
im using model called Photo that references Uploader class..
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且文件也未存储。)
but.. when i try to save new Album (or edit, whatever..) with image it not save a file (the collumn photo_image is saved as NULL and file not stored too.
... views / albums / _form.html.erb
... 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
添加到 attr_accessible
在Photo模型中,也许可以为您提供帮助。
just try to add :photo_image
to attr_accessible
at Photo model, it's maybe could help you.
还请检查您的日志/开发。日志
这篇关于CarrierWave在文件列中保存NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文