Created
June 12, 2013 02:17
-
-
Save tomelm/5762380 to your computer and use it in GitHub Desktop.
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 Appointment < ActiveRecord::Base | |
has_many :steps | |
has_many :roles, through: :steps | |
has_many :events, through: :roles | |
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 Event < ActiveRecord::Base | |
belongs_to :role | |
# access appointment by doing event.role.step.appointment | |
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 Role < ActiveRecord::Base | |
has_many :events | |
belongs_to :step | |
# access appointment by doing role.step.appointment | |
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
# /appointments/ | |
# /appointments/1/ | |
# /appointments/new | |
resources :appointments do | |
# /steps/1 | |
# /appointments/1/steps/new | |
# /steps/1/edit | |
resources :steps, shallow: true do | |
# /steps/1/roles/new | |
# /roles/1/edit | |
# /roles/1 | |
resources :roles, shallow: true do | |
# /roles/1/events/new | |
# /roles/1/events/ | |
# /events/1 | |
# /events/1/edit | |
resources :events, shallow: true | |
end | |
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 Step < ActiveRecord::Base | |
has_many :roles | |
has_many :events, through: :roles | |
belongs_to :appointment | |
#access appointment by doing step.appointment | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment