CarrierWave stores NULL in a file column

im using the Photo model, which refers to the 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 a new album (or edit anything ..) with an image, it does not save the file (a copy of photo_image is saved as NULL, and the file is also not saved.

... 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
source share
1 answer

just try adding :photo_image to attr_accessible to the model, maybe this can help you.

Also check your log/development.log

+3
source

Source: https://habr.com/ru/post/1402186/


All Articles