-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Ruby on Rails | Add enums section to Active Record Queries lesson #29099
Comments
Hi @sean-garwood thank you for making this issue. I agree that there's probably room for exploring enums in the curriculum. I think if they're going to be mentioned, there should be some content in the lesson itself for them though rather than fully delegating to external sources/links. Would you be comfortable writing some lesson content around enums? I'll offer some guidance on this if you're okay to proceed on that. Another thing to consider: no project currently requires enums explicitly. If we're going to mention them, we should probably introduce something in one of the projects for the learner to practice with them. One idea I had off the top of my head is that in Private Events, there could maybe be an enum field for the visibility of the |
Yep! Happy to add a few paragraphs and some links--maybe after the scopes section?
Agree that it would be worthwhile to practice using them in a project. I am using them in the final project to track the status of friend requests e.g. class FollowRequest < ApplicationRecord
belongs_to :user
belongs_to :recipient, class_name: "User", foreign_key: "recipient_id"
enum :status, { pending: 0, accepted: 1, rejected: 2, blocked: 3 } Seems to fit nicely in any use case where discrete states exist and are used to filter/query records. |
That makes sense to me. I would probably add both links you have in the OP of this issue (the documentation and the article) to the assignment section of the lesson. With the actual content, I think after the scopes section seems perfect to me. Some rough guidelines for how I'm envisioning this: (feel free to ask any further questions or push back on something you disagree with) Do Mention
Avoid Mentioning
Another thing to keep in mind: you'll want to add a point to the Lesson Overview and Knowledge Check sections for enums.
Yeah, that's a great place to potentially use them. I'd be fine with some callout in that project's specs that mentions |
Also I'll assign you for this. Again, let me know if you have any questions or concerns! |
chore: model decl * instance/class methods Add issue number fix: big o complexity
Add lesson content: section on enums * use cases * benefits * readability * maintainability * speed * disk space * how to implement * model * migration * warn about changing persisted data after change to enum declaration * comparison to scopes * class/instance methods exposed
Checks
Describe your suggestion
Introduce enums and show how they can be used.
Path
Ruby / Rails
Lesson Url
https://www.theodinproject.com/lessons/ruby-on-rails-active-record-queries
(Optional) Discord Name
seansg
(Optional) Additional Comments
The text was updated successfully, but these errors were encountered: