paperclip 2.8.0 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of paperclip might be problematic. Click here for more details.

Files changed (94) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +9 -7
  3. data/Appraisals +6 -12
  4. data/Gemfile +2 -0
  5. data/NEWS +24 -0
  6. data/README.md +53 -21
  7. data/Rakefile +7 -2
  8. data/UPGRADING +14 -0
  9. data/features/basic_integration.feature +8 -8
  10. data/features/rake_tasks.feature +1 -1
  11. data/features/step_definitions/attachment_steps.rb +11 -2
  12. data/features/step_definitions/rails_steps.rb +17 -79
  13. data/features/support/env.rb +3 -0
  14. data/features/support/file_helpers.rb +24 -0
  15. data/features/support/rails.rb +3 -3
  16. data/gemfiles/{rails3_1.gemfile → 3.0.gemfile} +3 -1
  17. data/gemfiles/{rails2.gemfile → 3.1.gemfile} +3 -1
  18. data/gemfiles/{rails3.gemfile → 3.2.gemfile} +3 -1
  19. data/images.rake +21 -0
  20. data/lib/generators/paperclip/paperclip_generator.rb +1 -2
  21. data/lib/paperclip.rb +48 -319
  22. data/lib/paperclip/attachment.rb +33 -81
  23. data/lib/paperclip/attachment_options.rb +0 -1
  24. data/lib/paperclip/callbacks.rb +30 -0
  25. data/lib/paperclip/errors.rb +27 -0
  26. data/lib/paperclip/geometry.rb +6 -4
  27. data/lib/paperclip/glue.rb +15 -0
  28. data/lib/paperclip/helpers.rb +71 -0
  29. data/lib/paperclip/instance_methods.rb +35 -0
  30. data/lib/paperclip/interpolations.rb +2 -2
  31. data/lib/paperclip/io_adapters/attachment_adapter.rb +62 -0
  32. data/lib/paperclip/io_adapters/file_adapter.rb +81 -0
  33. data/lib/paperclip/io_adapters/identity_adapter.rb +12 -0
  34. data/lib/paperclip/io_adapters/nil_adapter.rb +34 -0
  35. data/lib/paperclip/io_adapters/registry.rb +32 -0
  36. data/lib/paperclip/io_adapters/stringio_adapter.rb +64 -0
  37. data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +63 -0
  38. data/lib/paperclip/locales/en.yml +17 -0
  39. data/lib/paperclip/logger.rb +21 -0
  40. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +1 -1
  41. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +2 -2
  42. data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +7 -7
  43. data/lib/paperclip/processor.rb +32 -17
  44. data/lib/paperclip/railtie.rb +10 -15
  45. data/lib/paperclip/storage/filesystem.rb +5 -14
  46. data/lib/paperclip/storage/fog.rb +2 -21
  47. data/lib/paperclip/storage/s3.rb +12 -29
  48. data/lib/paperclip/tempfile.rb +41 -0
  49. data/lib/paperclip/thumbnail.rb +2 -3
  50. data/lib/paperclip/validators.rb +45 -0
  51. data/lib/paperclip/validators/attachment_content_type_validator.rb +47 -0
  52. data/lib/paperclip/validators/attachment_presence_validator.rb +26 -0
  53. data/lib/paperclip/validators/attachment_size_validator.rb +102 -0
  54. data/lib/paperclip/version.rb +1 -1
  55. data/lib/tasks/paperclip.rake +3 -11
  56. data/paperclip.gemspec +15 -5
  57. data/test/adapter_registry_test.rb +32 -0
  58. data/test/attachment_adapter_test.rb +48 -0
  59. data/test/attachment_options_test.rb +0 -13
  60. data/test/attachment_test.rb +27 -55
  61. data/test/file_adapter_test.rb +43 -0
  62. data/test/generator_test.rb +78 -0
  63. data/test/geometry_test.rb +5 -5
  64. data/test/helper.rb +9 -11
  65. data/test/identity_adapter_test.rb +8 -0
  66. data/test/integration_test.rb +39 -94
  67. data/test/interpolations_test.rb +8 -1
  68. data/test/matchers/validate_attachment_size_matcher_test.rb +16 -2
  69. data/test/nil_adapter_test.rb +25 -0
  70. data/test/paperclip_test.rb +30 -189
  71. data/test/storage/filesystem_test.rb +0 -14
  72. data/test/storage/fog_test.rb +0 -14
  73. data/test/storage/s3_live_test.rb +22 -9
  74. data/test/storage/s3_test.rb +70 -34
  75. data/test/stringio_adapter_test.rb +42 -0
  76. data/test/style_test.rb +10 -16
  77. data/test/thumbnail_test.rb +16 -10
  78. data/test/uploaded_file_adapter_test.rb +98 -0
  79. data/test/validators/attachment_content_type_validator_test.rb +140 -0
  80. data/test/validators/attachment_presence_validator_test.rb +85 -0
  81. data/test/validators/attachment_size_validator_test.rb +207 -0
  82. data/test/validators_test.rb +25 -0
  83. metadata +152 -30
  84. data/gemfiles/rails3_2.gemfile +0 -9
  85. data/generators/paperclip/USAGE +0 -5
  86. data/generators/paperclip/paperclip_generator.rb +0 -27
  87. data/generators/paperclip/templates/paperclip_migration.rb.erb +0 -19
  88. data/init.rb +0 -4
  89. data/lib/paperclip/callback_compatibility.rb +0 -61
  90. data/lib/paperclip/iostream.rb +0 -45
  91. data/lib/paperclip/upfile.rb +0 -64
  92. data/rails/init.rb +0 -2
  93. data/test/iostream_test.rb +0 -71
  94. data/test/upfile_test.rb +0 -53
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 3.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-07 00:00:00.000000000 Z
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.3.0
21
+ version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,23 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.3.0
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: activemodel
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.0
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: activesupport
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +50,7 @@ dependencies:
34
50
  requirements:
35
51
  - - ! '>='
36
52
  - !ruby/object:Gem::Version
37
- version: 2.3.2
53
+ version: 3.0.0
38
54
  type: :runtime
39
55
  prerelease: false
40
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +58,7 @@ dependencies:
42
58
  requirements:
43
59
  - - ! '>='
44
60
  - !ruby/object:Gem::Version
45
- version: 2.3.2
61
+ version: 3.0.0
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: cocaine
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -125,6 +141,22 @@ dependencies:
125
141
  version: '0'
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: aws-sdk
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 1.3.8
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.3.8
158
+ - !ruby/object:Gem::Dependency
159
+ name: bourne
128
160
  requirement: !ruby/object:Gem::Requirement
129
161
  none: false
130
162
  requirements:
@@ -146,7 +178,7 @@ dependencies:
146
178
  requirements:
147
179
  - - ~>
148
180
  - !ruby/object:Gem::Version
149
- version: 1.3.5
181
+ version: 1.3.4
150
182
  type: :development
151
183
  prerelease: false
152
184
  version_requirements: !ruby/object:Gem::Requirement
@@ -154,7 +186,7 @@ dependencies:
154
186
  requirements:
155
187
  - - ~>
156
188
  - !ruby/object:Gem::Version
157
- version: 1.3.5
189
+ version: 1.3.4
158
190
  - !ruby/object:Gem::Dependency
159
191
  name: cucumber
160
192
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +219,22 @@ dependencies:
187
219
  - - ! '>='
188
220
  - !ruby/object:Gem::Version
189
221
  version: '0'
222
+ - !ruby/object:Gem::Dependency
223
+ name: nokogiri
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ~>
228
+ - !ruby/object:Gem::Version
229
+ version: 1.4.7
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: 1.4.7
190
238
  - !ruby/object:Gem::Dependency
191
239
  name: capybara
192
240
  requirement: !ruby/object:Gem::Requirement
@@ -226,7 +274,7 @@ dependencies:
226
274
  requirements:
227
275
  - - ~>
228
276
  - !ruby/object:Gem::Version
229
- version: 0.4.0
277
+ version: '0.2'
230
278
  type: :development
231
279
  prerelease: false
232
280
  version_requirements: !ruby/object:Gem::Requirement
@@ -234,7 +282,7 @@ dependencies:
234
282
  requirements:
235
283
  - - ~>
236
284
  - !ruby/object:Gem::Version
237
- version: 0.4.0
285
+ version: '0.2'
238
286
  - !ruby/object:Gem::Dependency
239
287
  name: fog
240
288
  requirement: !ruby/object:Gem::Requirement
@@ -251,6 +299,38 @@ dependencies:
251
299
  - - ! '>='
252
300
  - !ruby/object:Gem::Version
253
301
  version: '0'
302
+ - !ruby/object:Gem::Dependency
303
+ name: pry
304
+ requirement: !ruby/object:Gem::Requirement
305
+ none: false
306
+ requirements:
307
+ - - ! '>='
308
+ - !ruby/object:Gem::Version
309
+ version: '0'
310
+ type: :development
311
+ prerelease: false
312
+ version_requirements: !ruby/object:Gem::Requirement
313
+ none: false
314
+ requirements:
315
+ - - ! '>='
316
+ - !ruby/object:Gem::Version
317
+ version: '0'
318
+ - !ruby/object:Gem::Dependency
319
+ name: launchy
320
+ requirement: !ruby/object:Gem::Requirement
321
+ none: false
322
+ requirements:
323
+ - - ! '>='
324
+ - !ruby/object:Gem::Version
325
+ version: '0'
326
+ type: :development
327
+ prerelease: false
328
+ version_requirements: !ruby/object:Gem::Requirement
329
+ none: false
330
+ requirements:
331
+ - - ! '>='
332
+ - !ruby/object:Gem::Version
333
+ version: '0'
254
334
  - !ruby/object:Gem::Dependency
255
335
  name: rake
256
336
  requirement: !ruby/object:Gem::Requirement
@@ -300,6 +380,7 @@ files:
300
380
  - NEWS
301
381
  - README.md
302
382
  - Rakefile
383
+ - UPGRADING
303
384
  - cucumber/paperclip_steps.rb
304
385
  - features/basic_integration.feature
305
386
  - features/rake_tasks.feature
@@ -310,6 +391,7 @@ files:
310
391
  - features/step_definitions/web_steps.rb
311
392
  - features/support/env.rb
312
393
  - features/support/fakeweb.rb
394
+ - features/support/file_helpers.rb
313
395
  - features/support/fixtures/.boot_config.rb.swo
314
396
  - features/support/fixtures/boot_config.txt
315
397
  - features/support/fixtures/gemfile.txt
@@ -317,24 +399,34 @@ files:
317
399
  - features/support/paths.rb
318
400
  - features/support/rails.rb
319
401
  - features/support/selectors.rb
320
- - gemfiles/rails2.gemfile
321
- - gemfiles/rails3.gemfile
322
- - gemfiles/rails3_1.gemfile
323
- - gemfiles/rails3_2.gemfile
324
- - generators/paperclip/USAGE
325
- - generators/paperclip/paperclip_generator.rb
326
- - generators/paperclip/templates/paperclip_migration.rb.erb
327
- - init.rb
402
+ - gemfiles/3.0.gemfile
403
+ - gemfiles/3.1.gemfile
404
+ - gemfiles/3.2.gemfile
405
+ - images.rake
406
+ - lib/.DS_Store
328
407
  - lib/generators/paperclip/USAGE
329
408
  - lib/generators/paperclip/paperclip_generator.rb
330
409
  - lib/generators/paperclip/templates/paperclip_migration.rb.erb
331
410
  - lib/paperclip.rb
411
+ - lib/paperclip/.DS_Store
332
412
  - lib/paperclip/attachment.rb
333
413
  - lib/paperclip/attachment_options.rb
334
- - lib/paperclip/callback_compatibility.rb
414
+ - lib/paperclip/callbacks.rb
415
+ - lib/paperclip/errors.rb
335
416
  - lib/paperclip/geometry.rb
417
+ - lib/paperclip/glue.rb
418
+ - lib/paperclip/helpers.rb
419
+ - lib/paperclip/instance_methods.rb
336
420
  - lib/paperclip/interpolations.rb
337
- - lib/paperclip/iostream.rb
421
+ - lib/paperclip/io_adapters/attachment_adapter.rb
422
+ - lib/paperclip/io_adapters/file_adapter.rb
423
+ - lib/paperclip/io_adapters/identity_adapter.rb
424
+ - lib/paperclip/io_adapters/nil_adapter.rb
425
+ - lib/paperclip/io_adapters/registry.rb
426
+ - lib/paperclip/io_adapters/stringio_adapter.rb
427
+ - lib/paperclip/io_adapters/uploaded_file_adapter.rb
428
+ - lib/paperclip/locales/en.yml
429
+ - lib/paperclip/logger.rb
338
430
  - lib/paperclip/matchers.rb
339
431
  - lib/paperclip/matchers/have_attached_file_matcher.rb
340
432
  - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
@@ -349,17 +441,23 @@ files:
349
441
  - lib/paperclip/storage/fog.rb
350
442
  - lib/paperclip/storage/s3.rb
351
443
  - lib/paperclip/style.rb
444
+ - lib/paperclip/tempfile.rb
352
445
  - lib/paperclip/thumbnail.rb
353
- - lib/paperclip/upfile.rb
354
446
  - lib/paperclip/url_generator.rb
447
+ - lib/paperclip/validators.rb
448
+ - lib/paperclip/validators/attachment_content_type_validator.rb
449
+ - lib/paperclip/validators/attachment_presence_validator.rb
450
+ - lib/paperclip/validators/attachment_size_validator.rb
355
451
  - lib/paperclip/version.rb
356
452
  - lib/tasks/paperclip.rake
357
453
  - paperclip.gemspec
358
- - rails/init.rb
359
454
  - shoulda_macros/paperclip.rb
455
+ - test/adapter_registry_test.rb
456
+ - test/attachment_adapter_test.rb
360
457
  - test/attachment_options_test.rb
361
458
  - test/attachment_test.rb
362
459
  - test/database.yml
460
+ - test/file_adapter_test.rb
363
461
  - test/fixtures/12k.png
364
462
  - test/fixtures/50x50.png
365
463
  - test/fixtures/5k.png
@@ -371,15 +469,17 @@ files:
371
469
  - test/fixtures/text.txt
372
470
  - test/fixtures/twopage.pdf
373
471
  - test/fixtures/uppercase.PNG
472
+ - test/generator_test.rb
374
473
  - test/geometry_test.rb
375
474
  - test/helper.rb
475
+ - test/identity_adapter_test.rb
376
476
  - test/integration_test.rb
377
477
  - test/interpolations_test.rb
378
- - test/iostream_test.rb
379
478
  - test/matchers/have_attached_file_matcher_test.rb
380
479
  - test/matchers/validate_attachment_content_type_matcher_test.rb
381
480
  - test/matchers/validate_attachment_presence_matcher_test.rb
382
481
  - test/matchers/validate_attachment_size_matcher_test.rb
482
+ - test/nil_adapter_test.rb
383
483
  - test/paperclip_missing_attachment_styles_test.rb
384
484
  - test/paperclip_test.rb
385
485
  - test/processor_test.rb
@@ -388,17 +488,29 @@ files:
388
488
  - test/storage/fog_test.rb
389
489
  - test/storage/s3_live_test.rb
390
490
  - test/storage/s3_test.rb
491
+ - test/stringio_adapter_test.rb
391
492
  - test/style_test.rb
392
493
  - test/support/mock_attachment.rb
393
494
  - test/support/mock_interpolator.rb
394
495
  - test/support/mock_model.rb
395
496
  - test/support/mock_url_generator_builder.rb
396
497
  - test/thumbnail_test.rb
397
- - test/upfile_test.rb
498
+ - test/uploaded_file_adapter_test.rb
398
499
  - test/url_generator_test.rb
500
+ - test/validators/attachment_content_type_validator_test.rb
501
+ - test/validators/attachment_presence_validator_test.rb
502
+ - test/validators/attachment_size_validator_test.rb
503
+ - test/validators_test.rb
399
504
  homepage: https://github.com/thoughtbot/paperclip
400
505
  licenses: []
401
- post_install_message:
506
+ post_install_message: ! "##################################################\n# NOTE
507
+ FOR UPGRADING FROM PRE-3.0 VERSION #\n##################################################\n\nPaperclip
508
+ 3.0 introduces a non-backward compatible change in your attachment\npath. This will
509
+ help to prevent attachment name clashes when you have\nmultiple attachments with
510
+ the same name. If you didn't alter your\nattachment's path and are using Paperclip's
511
+ default, you'll have to add\n`:path` and `:url` to your `has_attached_file` definition.
512
+ For example:\n\n has_attached_file :avatar,\n :path => \":rails_root/public/system/:attachment/:id/:style/:filename\",\n
513
+ \ :url => \"/system/:attachment/:id/:style/:filename\"\n\n"
402
514
  rdoc_options: []
403
515
  require_paths:
404
516
  - lib
@@ -407,7 +519,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
407
519
  requirements:
408
520
  - - ! '>='
409
521
  - !ruby/object:Gem::Version
410
- version: '0'
522
+ version: 1.9.2
411
523
  required_rubygems_version: !ruby/object:Gem::Requirement
412
524
  none: false
413
525
  requirements:
@@ -417,7 +529,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
417
529
  requirements:
418
530
  - ImageMagick
419
531
  rubyforge_project: paperclip
420
- rubygems_version: 1.8.24
532
+ rubygems_version: 1.8.21
421
533
  signing_key:
422
534
  specification_version: 3
423
535
  summary: File attachments as attributes for ActiveRecord
@@ -431,6 +543,7 @@ test_files:
431
543
  - features/step_definitions/web_steps.rb
432
544
  - features/support/env.rb
433
545
  - features/support/fakeweb.rb
546
+ - features/support/file_helpers.rb
434
547
  - features/support/fixtures/.boot_config.rb.swo
435
548
  - features/support/fixtures/boot_config.txt
436
549
  - features/support/fixtures/gemfile.txt
@@ -438,9 +551,12 @@ test_files:
438
551
  - features/support/paths.rb
439
552
  - features/support/rails.rb
440
553
  - features/support/selectors.rb
554
+ - test/adapter_registry_test.rb
555
+ - test/attachment_adapter_test.rb
441
556
  - test/attachment_options_test.rb
442
557
  - test/attachment_test.rb
443
558
  - test/database.yml
559
+ - test/file_adapter_test.rb
444
560
  - test/fixtures/12k.png
445
561
  - test/fixtures/50x50.png
446
562
  - test/fixtures/5k.png
@@ -452,15 +568,17 @@ test_files:
452
568
  - test/fixtures/text.txt
453
569
  - test/fixtures/twopage.pdf
454
570
  - test/fixtures/uppercase.PNG
571
+ - test/generator_test.rb
455
572
  - test/geometry_test.rb
456
573
  - test/helper.rb
574
+ - test/identity_adapter_test.rb
457
575
  - test/integration_test.rb
458
576
  - test/interpolations_test.rb
459
- - test/iostream_test.rb
460
577
  - test/matchers/have_attached_file_matcher_test.rb
461
578
  - test/matchers/validate_attachment_content_type_matcher_test.rb
462
579
  - test/matchers/validate_attachment_presence_matcher_test.rb
463
580
  - test/matchers/validate_attachment_size_matcher_test.rb
581
+ - test/nil_adapter_test.rb
464
582
  - test/paperclip_missing_attachment_styles_test.rb
465
583
  - test/paperclip_test.rb
466
584
  - test/processor_test.rb
@@ -469,12 +587,16 @@ test_files:
469
587
  - test/storage/fog_test.rb
470
588
  - test/storage/s3_live_test.rb
471
589
  - test/storage/s3_test.rb
590
+ - test/stringio_adapter_test.rb
472
591
  - test/style_test.rb
473
592
  - test/support/mock_attachment.rb
474
593
  - test/support/mock_interpolator.rb
475
594
  - test/support/mock_model.rb
476
595
  - test/support/mock_url_generator_builder.rb
477
596
  - test/thumbnail_test.rb
478
- - test/upfile_test.rb
597
+ - test/uploaded_file_adapter_test.rb
479
598
  - test/url_generator_test.rb
480
- has_rdoc:
599
+ - test/validators/attachment_content_type_validator_test.rb
600
+ - test/validators/attachment_presence_validator_test.rb
601
+ - test/validators/attachment_size_validator_test.rb
602
+ - test/validators_test.rb
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "jruby-openssl", :platform=>:jruby
6
- gem "rails", "~> 3.2.0"
7
- gem "paperclip", :path=>"../"
8
-
9
- gemspec :path=>"../"
@@ -1,5 +0,0 @@
1
- Usage:
2
-
3
- script/generate paperclip Class attachment1 (attachment2 ...)
4
-
5
- This will create a migration that will add the proper columns to your class's table.
@@ -1,27 +0,0 @@
1
- class PaperclipGenerator < Rails::Generator::NamedBase
2
- attr_accessor :attachments, :migration_name
3
-
4
- def initialize(args, options = {})
5
- super
6
- @class_name, @attachments = args[0], args[1..-1]
7
- end
8
-
9
- def manifest
10
- file_name = generate_file_name
11
- @migration_name = file_name.camelize
12
- record do |m|
13
- m.migration_template "paperclip_migration.rb.erb",
14
- File.join('db', 'migrate'),
15
- :migration_file_name => file_name
16
- end
17
- end
18
-
19
- private
20
-
21
- def generate_file_name
22
- names = attachments.map{|a| a.underscore }
23
- names = names[0..-2] + ["and", names[-1]] if names.length > 1
24
- "add_attachments_#{names.join("_")}_to_#{@class_name.underscore}"
25
- end
26
-
27
- end
@@ -1,19 +0,0 @@
1
- class <%= migration_name %> < ActiveRecord::Migration
2
- def self.up
3
- <% attachments.each do |attachment| -%>
4
- add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string
5
- add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string
6
- add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer
7
- add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime
8
- <% end -%>
9
- end
10
-
11
- def self.down
12
- <% attachments.each do |attachment| -%>
13
- remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name
14
- remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type
15
- remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size
16
- remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at
17
- <% end -%>
18
- end
19
- end