Open sean-garwood opened 2 days ago
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 events
? Let me know if you have any thoughts on this.
Would you be comfortable writing some lesson content around enums?
Yep! Happy to add a few paragraphs and some links--maybe after the scopes section?
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
events
? Let me know if you have any thoughts on this.
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.
Yep! Happy to add a few paragraphs and some links--maybe after the scopes section?
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)
Article.published
, @article.published?
, @article.published!
, etc.).enum
works but it's also how has_many
works, and we don't go into the behind the scenes details on that when teaching associations. Metaprogramming can be a big rabbit role, and I'd rather avoid going into it.enum :status { draft: 0, published: 1 }, suffix: true
so a query would become Article.draft_status
. This stuff is a bit more niche and is better to leave to the docs and the article you have.Another thing to keep in mind: you'll want to add a point to the Lesson Overview and Knowledge Check sections for enums.
I am using them in the final project to track the status of friend requests e.g.
Yeah, that's a great place to potentially use them. I'd be fine with some callout in that project's specs that mentions enums
as a way to manage the state of Friend/Follow Requests.
Also I'll assign you for this. Again, let me know if you have any questions or concerns!
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