-
-
Save entity1991/11364266 to your computer and use it in GitHub Desktop.
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
ActiveAdmin.register Project do | |
# Don't forget to add the image attribute (here thumbnails) to permitted_params | |
controller do | |
def permitted_params | |
params.permit project: [:title, :summary, :description, :thumbnail, :date, :url, :client_list, :technology_list, :type_list] | |
end | |
end | |
form do |f| | |
f.inputs "Project Details" do | |
f.input :title | |
f.input :thumbnail, :as => :file, :hint => f.template.image_tag(f.object.thumbnail.url(:thumb)) | |
# Will preview the image when the object is edited | |
end | |
f.actions | |
end | |
show do |ad| | |
attributes_table do | |
row :title | |
row :thumbnail do | |
image_tag(ad.thumbnail.url(:thumb)) | |
end | |
# Will display the image on show object page | |
end | |
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
class Project < ActiveRecord::Base | |
has_attached_file :thumbnail, :styles => { :medium => "300x300#", :thumb => "200x200#" } | |
# 200x200# crop the image | |
# 200x200> scale the image to 200px wide at maximum keeping aspect ratio | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment