From d068aa47cf495b143fbbdfaa754c6ccf91efa77c Mon Sep 17 00:00:00 2001 From: Victor Morandini Stabile Date: Tue, 29 May 2018 15:44:12 -0300 Subject: [PATCH 1/2] require dependencies --- lib/plutus.rb | 3 +++ plutus.gemspec | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/plutus.rb b/lib/plutus.rb index ec12afd9..ea54da71 100644 --- a/lib/plutus.rb +++ b/lib/plutus.rb @@ -1,5 +1,8 @@ # Plutus require "rails" +require "jquery-rails" +require "jquery-ui-rails" +require "kaminari" module Plutus class Engine < Rails::Engine diff --git a/plutus.gemspec b/plutus.gemspec index 1735bb9e..93f817a3 100644 --- a/plutus.gemspec +++ b/plutus.gemspec @@ -20,9 +20,9 @@ Gem::Specification.new do |s| "README.markdown" ] s.add_dependency("rails", "> 4.0") - s.add_dependency("jquery-rails", ">= 3.0") - s.add_dependency("jquery-ui-rails", ">= 4.2.2") - s.add_dependency("kaminari", "~> 1.0") + s.add_dependency("jquery-rails", "~> 4.0") + s.add_dependency("jquery-ui-rails", "~> 5.0") + s.add_dependency("kaminari", "~> 1.1") s.add_development_dependency("yard") s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE", "Rakefile", "README.markdown"] s.homepage = %q{http://github.com/mbulat/plutus} @@ -40,4 +40,3 @@ Gem::Specification.new do |s| else end end - From cb7158f38e60873f675d9c511bcf6d78d1fcf384 Mon Sep 17 00:00:00 2001 From: Victor Morandini Stabile Date: Tue, 29 May 2018 15:58:37 -0300 Subject: [PATCH 2/2] Destroy dependency --- app/models/plutus/account.rb | 2 +- app/models/plutus/entry.rb | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/models/plutus/account.rb b/app/models/plutus/account.rb index c26ee54e..4f2edc6f 100644 --- a/app/models/plutus/account.rb +++ b/app/models/plutus/account.rb @@ -35,7 +35,7 @@ class Account < ActiveRecord::Base has_many :amounts has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount' has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount' - has_many :entries, through: :amounts, source: :entry + has_many :entries, through: :amounts, source: :entry, :dependent => :destroy has_many :credit_entries, :through => :credit_amounts, :source => :entry, :class_name => 'Plutus::Entry' has_many :debit_entries, :through => :debit_amounts, :source => :entry, :class_name => 'Plutus::Entry' diff --git a/app/models/plutus/entry.rb b/app/models/plutus/entry.rb index ec951337..7045aa24 100644 --- a/app/models/plutus/entry.rb +++ b/app/models/plutus/entry.rb @@ -30,10 +30,14 @@ class Entry < ActiveRecord::Base belongs_to :commercial_document, :polymorphic => true end - has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount', :inverse_of => :entry - has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount', :inverse_of => :entry - has_many :credit_accounts, :through => :credit_amounts, :source => :account, :class_name => 'Plutus::Account' - has_many :debit_accounts, :through => :debit_amounts, :source => :account, :class_name => 'Plutus::Account' + has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount', + :inverse_of => :entry, :dependent => :destroy + has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount', + :inverse_of => :entry, :dependent => :destroy + has_many :credit_accounts, :through => :credit_amounts, :source => :account, + :class_name => 'Plutus::Account' + has_many :debit_accounts, :through => :debit_amounts, :source => :account, + :class_name => 'Plutus::Account' validates_presence_of :description validate :has_credit_amounts?