Refactor Rails models using Concerns

Rails developers like to repeat some phrase like “Convetion Over Configuration”, “Fat Model, Skinny Controller” or “Don’t Repeat Yourself”. Today I am going to focus on the last one: how we can minimze the repeated code in your models using Concerns.

[Here write more about concerns]

https://discuss.rubyonrails.org/t/helping-devs-understand-concerns-faster/74619/22?u=software_writer

To read: https://codeclimate.com/blog/7-ways-to-decompose-fat-activerecord-models/ https://reactjs.org/blog/2016/07/13/mixins-considered-harmful.html https://www.rubypigeon.com/posts/rails-models-bloated-should-i-use-concerns/ https://www.cloudbees.com/blog/when-to-be-concerned-about-concerns

Questions from forum: “What do you get by extending ActiveSupport::Concern?” “Why is there a different name in rails for a mixins?” “When are we using concerns”

Written on April 10, 2022

Recent posts: