Last active
December 4, 2020 05:37
-
-
Save ckk-scratch/ebca69b2dea368e7fbad1cad505d5cff to your computer and use it in GitHub Desktop.
Rails Admin dropzone config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Project < ActiveRecord::Base | |
extend FriendlyId | |
friendly_id :title, use: :slugged | |
has_and_belongs_to_many :artists | |
has_many :gallery_images | |
belongs_to :category | |
has_attached_file :hero, styles: { large: "1280x1024>", medium: "650x650" } | |
validates_attachment_content_type :hero, content_type: /\Aimage\/.*\Z/ | |
# Method | |
def create_associated_image(image) | |
gallery_images.create(image: image) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RailsAdmin.config do |config| | |
config.model 'Project' do | |
list do | |
exclude_fields_if do | |
type == :datetime | |
end | |
exclude_fields :gallery_images | |
exclude_fields :artists | |
end | |
end | |
config.model 'Artist' do | |
list do | |
exclude_fields_if do | |
type == :datetime | |
end | |
end | |
end | |
config.model 'Category' do | |
list do | |
exclude_fields_if do | |
type == :datetime | |
end | |
end | |
end | |
config.actions do | |
dashboard # mandatory | |
index # mandatory | |
new | |
dropzone do | |
only Project | |
end | |
export | |
bulk_delete | |
show | |
edit | |
delete | |
show_in_app | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment