- Concerns are helpers that are used to slim down the codes in models
and the controllers.
- Primary logic to implement are fatty models and skinny controllers.
- According to the rubocop guidelines, the possible LOC allowed in a file is 100 to 120 in a file.
- we can create model concerns, controller concerns.
- in order to use that, we need to add the folders to application.rb saying that these folders are selected for the code execution.
- need to create a folder inside the models folder called concerns
- Suppose we have a specific Requirement to handle and we do not want trouble this code with existing work flow, then we can use concerns are in place.
1.create folders called concerns:
Need to create the folders in app/models as well as the app/controllers
2.Add path to Application.rb
need to add the folder path to application.rb to include these files are needed.
3. save the file inside the concerns directory:
create a file called concern_test.rb in to app/models/concerns/
#here we can include class methods as well as the instance methods.
Thats it .Now your code works like charm. If you are using sublime, It has auto typing features will do the rest of the codes entering.