Open
Conversation
added 14 commits
August 3, 2021 09:55
This _should_ make querying for related projects easier...
Allows for reusability across other controllers.
JoeCatling
reviewed
Sep 13, 2021
| end | ||
|
|
||
| def destroy | ||
| @other_project = @project_relationship.projects.detect { |project| project != @project } |
Contributor
There was a problem hiding this comment.
More of a question than anything - would where.not(id: @project.id) be more efficient?
Contributor
Author
There was a problem hiding this comment.
Good spot, and you're absolutely right.
It's still one DB hit, but the difference is in loading one record into memory rather than two. There are times when relying on the preloaded/cached association would be beneficial but this isn't one of those instances :D
This code was a remnant from when associations weren't as fleshed out as they are now and project_relationships.projects was just an enumerable wrapper around the two belongs_to associations.
I'll push a commit with your suggested change 👍
added 2 commits
September 14, 2021 09:41
$ Conflicts: $ app/views/projects/application/_form.html.erb $ config/locales/en.yml $ db/structure.sql $ test/models/project_test.rb
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per request to change project linkage from a parent/child type relationship to a many-to-many relationship.
I think there's more that could be done but let's see how far this gets us to start with...