Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Web Developer Interviews:BootstrapFront End Web DeveloperHTML DeveloperHybrid Application DeveloperInternee PHP DeveloperJnr PHP/Codeigniter DeveloperJunior Developer PHPLaravel PHP DeveloperPython DeveloperRuby DeveloperTypographyWeb Developer & DesignerWeb Developer Cum SEO AnalystWeb Development NinjasWebsite DeveloperWordPress Themes Developer
Copyright © 2018. All Rights Reserved
Ruby Developer Interview Question:
Explain me what is the difference between concern and application_controller.rb in ruby on rails?
Submitted by: MuhammadAd
Concerns are basically modules that get mixed into controller or model classes for instance. A Concern extends ActiveSupport::Concern module. It helps slim down the model/controller classes, and makes it easier to reuse common code across multiple model/controller classes. Concerns are like helper modules. We can define helper methods in concerns and can include or extend those concerns from various controller/model classes to sharing and DRY up the model/controller code.
On the other hand, ApplicationController is a controller class (NOT a module) and in your Rails application, it is the base class from which all of your other controllers classes are derived from. e.g.
class FooController < ApplicationController
. . .
end
class BarController < ApplicationController
. . .
end
In, Model–View–Controller (MVC) software architectural pattern, a controller implements business logics, can send commands to the model to update the model's state. It can also send commands to its associated view to change the view's presentation of the model. ApplicationController is that kind where as the Concerns are like helpers to get their job done.
Additional - Using concerns/services you can put your business logic in the controller; as a controller should not be business logic heavy, its main work is to get the request and get the response out.
Submitted by: Muhammad
On the other hand, ApplicationController is a controller class (NOT a module) and in your Rails application, it is the base class from which all of your other controllers classes are derived from. e.g.
class FooController < ApplicationController
. . .
end
class BarController < ApplicationController
. . .
end
In, Model–View–Controller (MVC) software architectural pattern, a controller implements business logics, can send commands to the model to update the model's state. It can also send commands to its associated view to change the view's presentation of the model. ApplicationController is that kind where as the Concerns are like helpers to get their job done.
Additional - Using concerns/services you can put your business logic in the controller; as a controller should not be business logic heavy, its main work is to get the request and get the response out.
Submitted by: Muhammad
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.

https://InterviewQuestionsAnswers.ORG.
