From 48858ad8f1fb46bc7951cb5c10c0e8f5f722172e Mon Sep 17 00:00:00 2001 From: Diego Henrique Domingues Date: Tue, 23 Aug 2016 21:54:14 -0300 Subject: [PATCH 1/3] Add Rails 5 support Since that belongs_to is required by default at Rails 5 we need to add the `inverse_of`option to has_many on the owner object or you will receive a validation error when you create try create it. --- lib/attachinary/orm/active_record/extension.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/attachinary/orm/active_record/extension.rb b/lib/attachinary/orm/active_record/extension.rb index 05946bfc..e8b400ce 100644 --- a/lib/attachinary/orm/active_record/extension.rb +++ b/lib/attachinary/orm/active_record/extension.rb @@ -15,10 +15,17 @@ def attachinary_orm_definition(options) class_name: '::Attachinary::File', conditions: { scope: options[:scope].to_s }, dependent: :destroy + elsif Rails::VERSION::MAJOR > 3 && Rails::VERSION::MAJOR < 5 + has_many :"#{relation}", + -> { where scope: options[:scope].to_s }, + as: :attachinariable, + class_name: '::Attachinary::File', + dependent: :destroy else has_many :"#{relation}", -> { where scope: options[:scope].to_s }, as: :attachinariable, + inverse_of: :attachinariable, class_name: '::Attachinary::File', dependent: :destroy end From 5e4bebccf1b231e6ceaa9e1f2ae3531190095cc5 Mon Sep 17 00:00:00 2001 From: Diego Henrique Domingues Date: Sat, 3 Feb 2018 12:44:56 -0200 Subject: [PATCH 2/3] Freeze the rails dependency to 5.2 version --- attachinary.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachinary.gemspec b/attachinary.gemspec index 8a8d8806..95bf3658 100644 --- a/attachinary.gemspec +++ b/attachinary.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] s.test_files = Dir["test/**/*"] - s.add_dependency 'rails', '>= 3.2' + s.add_dependency 'rails', '>= 3.2', '< 5.2' s.add_dependency 'cloudinary', '~> 1.1.0' s.add_development_dependency 'sqlite3' From 559838bfb70adbb1573a4143309751bf0a82a3ad Mon Sep 17 00:00:00 2001 From: Diego Henrique Domingues Date: Sun, 4 Feb 2018 13:04:02 -0200 Subject: [PATCH 3/3] Update cloudinary version to 1.8 --- attachinary.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachinary.gemspec b/attachinary.gemspec index 95bf3658..1b1272db 100644 --- a/attachinary.gemspec +++ b/attachinary.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.test_files = Dir["test/**/*"] s.add_dependency 'rails', '>= 3.2', '< 5.2' - s.add_dependency 'cloudinary', '~> 1.1.0' + s.add_dependency 'cloudinary', '~> 1.8' s.add_development_dependency 'sqlite3' s.add_development_dependency 'rspec-rails'