Ruby on Rails | Concerning in Rails

TypeFast
www.typefast.co/
Concerning is a feature in Ruby on Rails that allows separation of concerns within the same model.
It is not a very wide known feature that is very handy if you are looking to better organize different sections of your code within the same model.
Concerning documentation: api.rubyonrails.org/v4.1.0/cl...

Пікірлер: 30

  • @happiguruman
    @happiguruman11 ай бұрын

    Thank you so much. I am learning lots of new concepts from your videos.

  • @midclock
    @midclock2 жыл бұрын

    Hi, I'm learning Ruby and rails, I've found this really interesting. Thank you!

  • @typefastco

    @typefastco

    2 жыл бұрын

    Welcome!

  • @InvincibleMan99
    @InvincibleMan992 жыл бұрын

    Very nice 👍

  • @typefastco

    @typefastco

    2 жыл бұрын

    Thank you 👍

  • @sufiyansiddique2874
    @sufiyansiddique28742 жыл бұрын

    This explanation helps me understand it well. Thanks a lot

  • @typefastco

    @typefastco

    2 жыл бұрын

    Glad to hear that!

  • @CharlesDv
    @CharlesDv2 жыл бұрын

    I've read some posts about disadvantages to use 'concerns'. In your example everything looks great. I'm not sure in which cases would be wrong. Thanks for the video.

  • @typefastco

    @typefastco

    2 жыл бұрын

    I don't think there's a perfect solution to everything. This is just an example on using Concerning to better organize your models.

  • @nathanieljones7268
    @nathanieljones72682 жыл бұрын

    Hi Chris! I'm building a quiz like app for a course project and would be interested to see how you implemented the "wizard" form to build the quizzes. Is this app an open source? Would be great to see how to implement these kinds of forms with ruby!

  • @typefastco

    @typefastco

    2 жыл бұрын

    Those are Tailwind UI forms. Check out tailwindcss.

  • @muhammadahmed1890
    @muhammadahmed18902 жыл бұрын

    i was oftenly asked a question in interviews, "what is the difference between modules and concerns?", can you please answer it ?

  • @typefastco

    @typefastco

    2 жыл бұрын

    Video coming this week for that on Wednesday

  • @vanshmittal767
    @vanshmittal7672 жыл бұрын

    Nice Explanation! if you could also cover Active::Record Associations, it would be great!

  • @typefastco

    @typefastco

    2 жыл бұрын

    Noted

  • @davidlegare5021
    @davidlegare50212 жыл бұрын

    Great video. Was just wondering why you didn't mention single table inheritance as one of the possible solutions to the scenario. Imo it's a much cleaner implementation.

  • @InvincibleMan99

    @InvincibleMan99

    2 жыл бұрын

    Yeah But it weird to see empty columns in STI

  • @typefastco

    @typefastco

    2 жыл бұрын

    You could, but I find that STI often introduces unnecessary complexity. I generally lean towards just creating a new model/table rather than inheriting. There are a few cases where STI is a great solution, but I think in this specific case, it is unneeded.

  • @nathanieljones7268
    @nathanieljones72683 жыл бұрын

    Saw that you actually also have a third role for the user namely "rogue". I assume this is the initial role and based on certain actions you update the role to be either "teacher" or a "student"? Great video! You should do a tutorial series on how to build something like this.

  • @typefastco

    @typefastco

    3 жыл бұрын

    "rogue" is for users who are in the sign up process. It's definitely not the best naming for sure 😅 Thank you for the feedback and if you have any suggestions on things you want me to cover (a thorough tutorial as well), do let me know and I'm happy to look into it 👍

  • @nathanieljones7268

    @nathanieljones7268

    3 жыл бұрын

    @@typefastco Tutorial on buliding something like this would be awesome! I assume that this is a real project you're developing and not open sourced so this naturally wouldn't be something you would cover?

  • @typefastco

    @typefastco

    3 жыл бұрын

    We can do something else as in building something brand new. Are you currently learning web development?

  • @nathanieljones7268

    @nathanieljones7268

    3 жыл бұрын

    @@typefastco Been doing web development with RoR for a while now, but very interested in the new technologies in the community. App covering ViewComponents, tailwind and presumeably alpine or stimulus would be definitely interesting.

  • @nathanieljones7268

    @nathanieljones7268

    3 жыл бұрын

    @@typefastco How about showing how to build something like the form you have here for building new questions for quizzes? It seems like a good way to get introduced to a bit of rails nested resources and also it seems that you're doing it in an interesting way from looking at the url that contains the step etc.

  • @johnquarto
    @johnquarto2 жыл бұрын

    what happens when you have a person who is a Student-Teacher ? (classic use of the Strategy Pattern)

  • @typefastco

    @typefastco

    2 жыл бұрын

    I have no idea. A person who's a student and a teacher at the same time?

  • @johnquarto

    @johnquarto

    2 жыл бұрын

    right, that's the question. You're saying things are better if you move it to a concern, but how are you addressing the issue of users who wear multiple hats (such as Student-Teachers) which is far more common than absolute strict no-chance-of-bleed-over roles?

  • @banest0

    @banest0

    2 жыл бұрын

    I would rather have one base model for authentication and then separate models for different kind of roles.

  • @typefastco

    @typefastco

    2 жыл бұрын

    @@banest0 If a user can have multiple roles, then roles table makes sense.