-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add pinned articles box to profiles #3269
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
Conversation
redirect_back(fallback_location: "/dashboard") | ||
end | ||
|
||
def update |
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.
Is there are reason why this is not the destroy action?
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'd need to look further into whether we have addressed this in updates since the fact, but going way back to this project's creation I removed the jquery dependency for Rails that was actually required for calling destroy
actions. I know Rails has since removed jquery as a dependency from the ujs
approach but I believe it is still the case that we can't call destroy actions in the Rails way without importing the specific dependencies, which we do on the "are you sure you want to destroy this" page.
We should definitely make get this documented and make some of these overall concepts around how we cache pages more clearly documented in our Readme/docs.
Anyway, I figured in and of itself update
was close enough to what's going on with updating the state of something's pinned status that it's clean enough for now.
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.
@benhalpern there's an example in the code that does something similar I guess. If you look at the code for removing the API key:
that's a POST with the method: :delete
trick that ends up in the destroy
action inside the api secrets controller https://github.com/thepracticaldev/dev.to/blob/master/app/controllers/api_secrets_controller.rb#L20
@@ -22,6 +22,7 @@ class Article < ApplicationRecord | |||
counter_culture :organization | |||
|
|||
has_many :comments, as: :commentable, inverse_of: :commentable | |||
has_many :profile_pins, as: :pinnable, inverse_of: :pinnable |
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.
Why does an article has many profile_pins? I don't understand. Shouldn't an article have at most one pin? Is this to allow the same article to be pinned by multiple people in an organization?
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 didn't build in the full functionality yet, but created the structure so that one article could be simultaneously pinned to a user, an organization and any of its tags. Each acts as a "profile" in this relationship.
What type of PR is this? (check all applicable)
Description
This feature should help folks highlight their most impactful stuff, while also being less hesitant to post simpler discussion/help threads etc. without pushing down their best content.