Last active
July 20, 2016 14:24
-
-
Save jdgarrido/6fb9768fc2c21a0f31ff93afcf2c1fe2 to your computer and use it in GitHub Desktop.
modelo papu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Comuna < ActiveRecord::Base | |
| belongs_to :provincia | |
| has_many :sede | |
| def to_s | |
| self.nombre | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AddComunaToSede < ActiveRecord::Migration | |
| def change | |
| add_reference :sedes, :comuna, index: true, foreign_key: true | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Provincia < ActiveRecord::Base | |
| belongs_to :region | |
| has_many :comunas | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Region < ActiveRecord::Base | |
| has_paper_trail | |
| has_and_belongs_to_many :partidos | |
| has_many :provincias | |
| has_many :comunas, through: :provincias | |
| has_many :distritos | |
| has_many :circunscripcions | |
| def to_s | |
| self.nombre | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Sede < ActiveRecord::Base | |
| has_paper_trail | |
| belongs_to :partido | |
| belongs_to :region | |
| belongs_to :comuna | |
| validates_presence_of :direccion, :region_id, :comuna_id | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment