CarrierWave save NULL at file column

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:39:16

问题


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

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

<%= f.fields_for :photos do |f| %>
    <div class="field">
    <%= f.label :photo_image %><br />
        <%= f.file_field :photo_image %>
    </div>
<% end %>

any suggestion?


回答1:


just try to add :photo_image to attr_accessible at Photo model, it's maybe could help you.

Also check your log/development.log



来源:https://stackoverflow.com/questions/9134339/carrierwave-save-null-at-file-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!