forked from railsadminteam/rails_admin
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
CarrierWave
        neofish edited this page Nov 8, 2012 
        ·
        9 revisions
      
    Once added to your Gemfile, and after bundle install has been run, Carrierwave is ready to be used with rails admin.  No further configuration is required to integrate it.
Your model should look like this:
class Article < ActiveRecord::Base
  mount_uploader :asset, AssetUploader
  # don't forget those if you use :attr_accessible (delete method and form caching method are provided by Carrierwave and used by RailsAdmin)
  attr_accessible :asset, :asset_cache, :remove_asset
endYou can specify the field as a 'carrierwave' type if not detected:
field :asset, :carrierwaveNow a file upload field will be added to your model's form.
If you have Asset model class as a polymorphic and you want thumbnail in you Article model. For first create association:
class Article < ActiveRecord::Base
  has_one :post_thumbnail, :as => :assetable, :class_name => Asset
endFor second in rails_admin.rb initializer say :post_thumbnail should be as a file tag.
config.model Asset do
  edit do
    field :asset, :carrierwave
  end
end
config.model Article do
  nested do
    field :post_thumbnail
  end
end