I want to use Attachinary in combination with rails_admin in Rails 4. I am using MongoID.
My problem is, that the upload is working fine, but when trying to save a record through rails_admin I get a validation error that the image is not present.
this is my model:
class Medium
include Mongoid::Document
include Mongoid::Timestamps
extend Enumerize
has_attachment :image, accept: [:jpg, :png, :gif]
accepts_nested_attributes_for :image
validates :title, :image, presence: true
field :title
rails_admin do
edit do
field :title
field :image do
partial 'direct_image_upload'
end
end
end
end
I had to use accepts_nested_attributes_for because else I got this error message:
Embbeded association without accepts_nested_attributes_for can't be handled by RailsAdmin, because embedded model doesn't have top-level access. Please add `accepts_nested_attributes_for :image' line to `Medium' model.
I want to use Attachinary in combination with rails_admin in Rails 4. I am using MongoID. My problem is, that the upload is working fine, but when trying to save a record through rails_admin I get a validation error that the image is not present.
this is my model:
I had to use
accepts_nested_attributes_for
because else I got this error message:This is my partial (HAML):
Do I need to create an additional
Image
model? Can't figure out why this is not working. Thank you very much for your help in advance.