-
Notifications
You must be signed in to change notification settings - Fork 2
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
Forms Refactoring -Add ability to reference single document in collection #512
Conversation
…ction From: https://eaflood.atlassian.net/browse/RUBY-693 In Wex, using Active Record, we were able to simplify a lot our logic around addresses forms by redefining the association to the address as `has_one` associations. Currently, there is no way to do the same with MongId 5.2, hence this adds some metaprogramming code that will allow a mode l to define a single object that is persisted inside a location and to override it.
78e000e
to
f690846
Compare
app/models/concerns/waste_carriers_engine/can_have_registration_attributes.rb
Outdated
Show resolved
Hide resolved
app/models/concerns/waste_carriers_engine/can_have_registration_attributes.rb
Show resolved
Hide resolved
registration.registration_type != registration_type | ||
end | ||
|
||
def registration |
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.
👍 ❤️
app/models/concerns/waste_carriers_engine/can_reference_single_document_in_collection.rb
Show resolved
Hide resolved
app/models/concerns/waste_carriers_engine/can_have_registration_attributes.rb
Outdated
Show resolved
Hide resolved
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.
Some grammar and typo suggestions for the comment
# This module's aim is to implement a way to reference documetns in collection but singularly | ||
# so that they can be treated as `has_one` associations. Currently on the WEX project we achieve the same | ||
# functionality thanks to ActiveRecord Relation ability of specify custom associations using default scopes. | ||
# But with the version of MongoId we use there is no ability of doing so. |
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.
# This module's aim is to implement a way to reference documetns in collection but singularly | |
# so that they can be treated as `has_one` associations. Currently on the WEX project we achieve the same | |
# functionality thanks to ActiveRecord Relation ability of specify custom associations using default scopes. | |
# But with the version of MongoId we use there is no ability of doing so. | |
# This module's aim is to implement a way to reference a single document in a | |
# collection so that they can then be treated as `has_one` associations. | |
# In projects using ActiveRecord like WEX we achieve the same functionality | |
# thanks to ActiveRecord's Relation ability to specify custom associations using | |
# default scopes. But because here we are using an old version of MongoDB, we | |
# are also stuck with a version of Mongoid which does not have this ability. |
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.
Turns out multiline comments don't apply to multiline suggestions
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.
yep it does not! Shame! :D
From: https://eaflood.atlassian.net/browse/RUBY-693
In Wex, using Active Record, we were able to simplify a lot our logic around addresses forms by redefining the association to the address as
has_one
associations.Currently, there is no way to do the same with MongId 5.2, hence this adds some metaprogramming code that will allow a mode l to define a single object that is persisted inside a location and to override it.