railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.91k stars 2.26k forks source link

CarrierWave and has_one polymorphic association uploading issue #2159

Open bypotatoes opened 9 years ago

bypotatoes commented 9 years ago

Receipt is described here https://github.com/sferik/rails_admin/wiki/CarrierWave

I've add picture association to Testimonial model:

# app/models/testimonial.rb
class Testimonial < ActiveRecord::Base
  belongs_to :project

  has_one :picture, as: :imageable, dependent: :destroy

  validates :project_id, :content, presence: true
end

and cofigure models for rails_admin:

# config/initializers/rails_admin.rb
RailsAdmin.config do |config|
  config.model Picture do
    edit do
      field :source, :carrierwave
    end
  end
  config.model Testimonial do
    nested do
      field :picture
    end
  end
end

but as result I got form with where input for file uploading was missed rails_admin_has_one

Could some suggest something?

mxmzb commented 9 years ago

Bump. I have run into this as well. Weirdly, it works fine with a has_many association, which would result in fact in the same database structure. I temporarily switched the has_one and belongs_to relations in my models so it works now, but I would like to switch back to the intended structure as soon as possible.