taxonomy_rails 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a91a710b7bb93ce740bae3cb034bbc0efd47cc2
4
- data.tar.gz: ca710b8e63394c39552ac24a6ff793b4768648fb
3
+ metadata.gz: b78283c1e2ee99c61e3ddda642c70141704e6b4c
4
+ data.tar.gz: 958efcd796094d8b04c7a11e2d0cdcc6a07f0053
5
5
  SHA512:
6
- metadata.gz: 4ff6ab9db1494550d66bde18dd6bcc3dbc075933c5e928bb2d6bc0b1d714bb63280b84a041bbe5a0d9c58cb132ddad546f5d86582e1b2f69e9c70dc18ed47f83
7
- data.tar.gz: 89fa944308d07323a67a2deef512aedba51ec14579057069cf3d691a83a30cc8f6fd1c27379acba1e8daae78a82b46d15e54b70201ffd375904a1f2b262c9a65
6
+ metadata.gz: 3e94fb52cb2f7ff526198214039eb75d218452f7f666be3604e87f554e31171990044a709177c1a3b4717386baf40ddb729a665f508e0f6e01a03a6dc0b24aa0
7
+ data.tar.gz: 00a9f1935703c9439361ae3e421ce34daac5154bb3b7d5c70e57cb0bdab9d3f35a0df9d7bd074b3b8c4d1c162ebc0dc4920520958fc1f9521bdd01e1cb6d4a95
@@ -1,7 +1,17 @@
1
1
  class Classification < ActiveRecord::Base
2
2
 
3
3
  belongs_to :taxon, inverse_of: :classifications
4
+ belongs_to :taxonomy, inverse_of: :classifications
4
5
  belongs_to :classifiable, polymorphic: true, inverse_of: :classification
5
6
 
6
- validates :taxon_id, presence: true
7
+ validates :taxon_id, :taxonomy_id, presence: true
8
+
9
+ before_validation :copy_taxonomy_id
10
+
11
+ protected
12
+
13
+ def copy_taxonomy_id
14
+ self.taxonomy_id = self.taxon.taxonomy_id if taxon.present?
15
+ end
16
+
7
17
  end
@@ -1,6 +1,7 @@
1
1
  class Taxonomy < ActiveRecord::Base
2
2
 
3
3
  has_many :taxons, inverse_of: :taxonomy, dependent: :destroy
4
+ has_many :classifications, inverse_of: :taxonomy, dependent: :destroy
4
5
 
5
6
  validates :name, presence: true
6
7
 
@@ -0,0 +1,6 @@
1
+ class AddTaxonomyIdToClassification < ActiveRecord::Migration
2
+ def change
3
+ add_reference :classifications, :taxonomy, index: true
4
+ add_foreign_key :classifications, :taxonomies
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module TaxonomyRails
2
- VERSION = '0.1.5'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taxonomy_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orgânica Digital
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,6 +87,7 @@ files:
87
87
  - db/migrate/20150205160750_create_classifications.rb
88
88
  - db/migrate/20150205164502_add_slug_to_taxon.rb
89
89
  - db/migrate/20150210151659_change_taxon_slug_unique_index.rb
90
+ - db/migrate/20150508130643_add_taxonomy_id_to_classification.rb
90
91
  - lib/generators/taxonomy_rails/taxonomy_rails_generator.rb
91
92
  - lib/taxonomy_rails.rb
92
93
  - lib/taxonomy_rails/engine.rb
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  version: '0'
112
113
  requirements: []
113
114
  rubyforge_project:
114
- rubygems_version: 2.4.6
115
+ rubygems_version: 2.4.5
115
116
  signing_key:
116
117
  specification_version: 4
117
118
  summary: A simple taxonomy hierarchy for use in Rails projects.