TheOdinProject / curriculum

The open curriculum for learning web development
https://www.theodinproject.com/
Other
10.12k stars 13.56k forks source link

Ruby on Rails | Add enums section to Active Record Queries lesson #29099

Open sean-garwood opened 2 days ago

sean-garwood commented 2 days ago

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

JoshDevHub commented 1 day 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.

sean-garwood commented 1 day ago

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.

JoshDevHub commented 1 day ago

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)

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.

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.

JoshDevHub commented 1 day ago

Also I'll assign you for this. Again, let me know if you have any questions or concerns!