问题
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