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 7db1168ed9a62ddfc3018a8ffafb817dfc512281 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/amount.rb | 2 +- app/models/plutus/entry.rb | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/plutus/account.rb b/app/models/plutus/account.rb index c26ee54e..b971877e 100644 --- a/app/models/plutus/account.rb +++ b/app/models/plutus/account.rb @@ -32,7 +32,7 @@ module Plutus class Account < ActiveRecord::Base class_attribute :normal_credit_balance - has_many :amounts + has_many :amounts, :dependent => :destroy 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 diff --git a/app/models/plutus/amount.rb b/app/models/plutus/amount.rb index 5b742701..3ed88c9d 100644 --- a/app/models/plutus/amount.rb +++ b/app/models/plutus/amount.rb @@ -6,7 +6,7 @@ module Plutus # # @author Michael Bulat class Amount < ActiveRecord::Base - belongs_to :entry, :class_name => 'Plutus::Entry' + belongs_to :entry, :class_name => 'Plutus::Entry', :dependent => :destroy belongs_to :account, :class_name => 'Plutus::Account' validates_presence_of :type, :amount, :entry, :account 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?