Skip to content

Commit 688ed88

Browse files
authored
Merge pull request #450 from platanus/remove-paperclip
Remove paperclip
2 parents 3f5a834 + f799a85 commit 688ed88

15 files changed

Lines changed: 14 additions & 375 deletions

Gemfile.lock

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ GEM
110110
capybara
111111
selenium-webdriver
112112
childprocess (3.0.0)
113-
climate_control (0.2.0)
114113
coderay (1.1.2)
115114
concurrent-ruby (1.1.10)
116115
content_disposition (1.0.0)
@@ -190,9 +189,6 @@ GEM
190189
marcel (1.0.2)
191190
matrix (0.4.2)
192191
method_source (0.9.2)
193-
mime-types (3.3.1)
194-
mime-types-data (~> 3.2015)
195-
mime-types-data (3.2019.1009)
196192
mini_magick (4.11.0)
197193
mini_mime (1.1.2)
198194
mini_portile2 (2.8.0)
@@ -205,12 +201,6 @@ GEM
205201
notiffany (0.1.3)
206202
nenv (~> 0.1)
207203
shellany (~> 0.0)
208-
paperclip (6.1.0)
209-
activemodel (>= 4.2.0)
210-
activesupport (>= 4.2.0)
211-
mime-types
212-
mimemagic (~> 0.3.0)
213-
terrapin (~> 0.6.0)
214204
parallel (1.19.1)
215205
parser (2.7.1.2)
216206
ast (~> 2.4.0)
@@ -335,8 +325,6 @@ GEM
335325
activesupport (>= 5.2)
336326
sprockets (>= 3.0.0)
337327
sqlite3 (1.4.2)
338-
terrapin (0.6.0)
339-
climate_control (>= 0.0.3, < 1.0)
340328
thor (1.2.1)
341329
tilt (2.1.0)
342330
tzinfo (2.0.5)
@@ -377,7 +365,6 @@ DEPENDENCIES
377365
image_processing
378366
matrix
379367
mimemagic!
380-
paperclip
381368
pry-rails
382369
puma
383370
rails (~> 6.1, >= 6.1.4.4)

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ ActiveAdmin Addons will extend your ActiveAdmin and enable a set of addons you c
77

88
#### Rows/Columns
99

10-
- [Paperclip Attachment](#paperclip-attachment): show file icons on your show/index views.
11-
- [Paperclip Image](#paperclip-image): show thumbnails on your show/index views.
10+
- [Shrine Image](#shrine-image): show thumbnails on your show/index views.
1211
- [AASM Integration](#aasm-integration): nice looking tags for states.
1312
- [Enumerize and Rails Enum Integration](#enumerize-and-rails-enum-integration): nice looking tags for enums.
1413
- [Boolean Values](#boolean-values): beautiful boolean values.
@@ -71,17 +70,9 @@ Installing this gem will enable the following changes by default:
7170

7271
### Rows/Columns
7372

74-
#### Paperclip Attachment
75-
76-
Displays a paperclip link with attachment related icon into index and show views.
77-
78-
<img src="./docs/images/paperclip-attachment-column.png" height="250" />
79-
80-
[Read more!](docs/paperclip_attachment.md)
81-
8273
#### Images
8374

84-
Display images in the index and show views. This implementation supports [Shrine](https://github.com/shrinerb/shrine) and [Paperclip](https://github.com/thoughtbot/paperclip).
75+
Display images in the index and show views. This implementation supports [Shrine](https://github.com/shrinerb/shrine).
8576

8677
<img src="./docs/images/paperclip-image-column.png" height="380" />
8778

activeadmin_addons.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Gem::Specification.new do |s|
3535
s.add_development_dependency "guard-rspec"
3636
s.add_development_dependency "image_processing"
3737
s.add_development_dependency "matrix"
38-
s.add_development_dependency "paperclip"
3938
s.add_development_dependency "pry-rails"
4039
s.add_development_dependency "puma"
4140
s.add_development_dependency "rails", "~> 6.1", ">= 6.1.4.4"

docs/images.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
11
# Images Integration
22

3-
## Paperclip
4-
5-
### Image Row
6-
7-
```ruby
8-
show do
9-
attributes_table do
10-
image_row :photo
11-
end
12-
end
13-
```
14-
15-
<img src="./images/paperclip-image-row.png" height="400" />
16-
17-
### Image Column
18-
19-
```ruby
20-
index do
21-
image_column :photo, style: :thumb
22-
end
23-
```
24-
25-
<img src="./images/paperclip-image-column.png" height="400" />
26-
27-
> You can pass `style` attribute matching paperclip's style definition
28-
293
## Shrine
304

315
### Image Row

docs/paperclip_attachment.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

lib/activeadmin_addons/addons/attachment_builder.rb

Lines changed: 0 additions & 60 deletions
This file was deleted.

lib/activeadmin_addons/addons/image_builder.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@ class ImageBuilder < CustomBuilder
33
def render
44
return nil if data.nil?
55

6-
if Object.const_defined?('Paperclip::Attachment') && data.is_a?(Paperclip::Attachment)
7-
paperclip_data
8-
elsif Object.const_defined?('Shrine::UploadedFile') && data.is_a?(Shrine::UploadedFile)
6+
if Object.const_defined?('Shrine::UploadedFile') && data.is_a?(Shrine::UploadedFile)
97
shrine_data
108
else
11-
raise "you need to pass a paperclip or shrine image attribute"
9+
raise "you need to pass a shrine image attribute"
1210
end
1311
end
1412

1513
private
1614

17-
def paperclip_data
18-
style = options.fetch(:style, :original)
19-
context.image_tag(data.url(style)) if data.file?
20-
end
21-
2215
def shrine_data
2316
image_options = options[:image_options].presence || {}
2417
if options[:style] && derivatives.include?(options[:style])

spec/dummy/app/admin/invoices.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ActiveAdmin.register Invoice do
2-
permit_params :legal_date, :number, :paid, :state, :attachment, :photo, :category_id, :city_id,
2+
permit_params :legal_date, :number, :paid, :state, :category_id, :city_id,
33
:amount, :color, :updated_at, :picture, :active, :description, item_ids: [], other_item_ids: []
44

55
filter :id, as: :numeric_range_filter
@@ -16,9 +16,7 @@
1616
id_column
1717
tag_column :state, interactive: true
1818
bool_column :paid
19-
image_column :photo, style: :thumb
2019
image_column :picture, style: :jpg_small
21-
attachment_column :attachment
2220
number_column :amount, as: :currency, unit: "$", separator: ","
2321
toggle_bool_column :active
2422
markdown_column :description
@@ -35,7 +33,6 @@
3533
list_row :skills, list_type: :ol
3634
list_row :contact, localize: true
3735
list_row :details, localize: true
38-
image_row("Mi foto", :photo, style: :big, &:photo)
3936
attachment_row("My doc", :attachment, label: 'Download file', truncate: false, &:attachment)
4037
image_row("Mi picture", :picture, image_options: { width: 100 }, &:picture)
4138
row :legal_date
@@ -85,14 +82,10 @@
8582

8683
f.input :other_item_ids, as: :tags, collection: Item.all.limit(5)
8784

88-
f.input :attachment
89-
9085
f.input :description
9186

9287
f.input :legal_date
9388

94-
f.input :photo
95-
9689
f.input :picture, as: :file
9790

9891
f.input :color, as: :color_picker,

spec/dummy/app/models/invoice.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
require 'enumerize'
2-
require 'paperclip'
32
require 'aasm'
43

54
class Invoice < ActiveRecord::Base
65
extend ::Enumerize
7-
include Paperclip::Glue
86
include AASM
97
include ImageUploader::Attachment(:picture)
108

@@ -17,16 +15,6 @@ class Invoice < ActiveRecord::Base
1715

1816
enum status: { active: 0, archived: 1 }
1917

20-
has_attached_file :attachment
21-
validates_attachment :attachment, content_type: { content_type: "application/pdf" }
22-
23-
has_attached_file :photo, styles: {
24-
big: "600x600>",
25-
medium: "300x300>",
26-
thumb: "100x100>"
27-
}
28-
29-
validates_attachment :photo, content_type: { content_type: %r{\Aimage\/.*\Z} }
3018

3119
# Uncomment to test validations
3220
# validates :city, :city_id, :category, :category_id, :updated_at, :number, :item_ids, :color,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class RemoveAttachmentFromInvoices < ActiveRecord::Migration[6.1]
2+
def change
3+
remove_attachment :invoices, :attachment
4+
remove_attachment :invoices, :photo
5+
end
6+
end

0 commit comments

Comments
 (0)