-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧹 Utility
: Use UtilityHookup#location
in forms
#1179
Conversation
- Extracted from htps://github.com//pull/1083 This is mostly for consistency and to start to close out a piece of work I started a while back but never finished.
@@ -4,6 +4,7 @@ | |||
class UtilityHookup < ApplicationRecord | |||
# @return [Space] | |||
belongs_to :space | |||
self.location_parent = :space |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see thatlocation_parent
was created for rails routing... but why do we need it? What is it logically doing?
convene/app/models/within_location.rb
Line 6 in 5313039
def location_parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It provides a url hierarchy when leveraging polymorphic routes. For example: /spaces/:space_id/utility_hookups
vs /utility_hookups/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok within_location.rb seems like a custom implementation and not something that come with rails.
I'll learn more about polymorphic routes on my own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, rails does not include it by default because most Rails
applications are flat; and it's often an anti-pattern to have too deeply nested of resources!
However, we need to keep models within the Room
or Space
; so we almost always have at least those two levels of nesting; plus any additional domain-specific nesting that Furniture
may want.
Utility
: Use #location
in formsUtility
: Use UtilityHookup#location
in forms
Space
: Fix broken forms and links when on aBYODomain
#1083This is mostly for consistency and to start to close out a piece of work I started a while back but never finished.