Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:18:41+00:00 2026-06-13T04:18:41+00:00

I am just getting into rails and begining to understand it slowly. Can someone

  • 0

I am just getting into rails and begining to understand it slowly. Can someone explain or give me ideas on the benefits or when and whys for coding inside the application_controller? What are some usecases. How are you using the application controller for your rails app? I dont want to put too much code in there because from what I understand, this controller gets called for every request. Is this true?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:18:42+00:00Added an answer on June 13, 2026 at 4:18 am

    ApplicationController is practically the class which every other controller in you application is going to inherit from (although this is not mandatory in any mean).

    I agree with the attitude of not messing it with too much code and keeping it clean and tidy, although there are some cases in which ApplicationController would be a good place to put your code at.
    For example: If you are working with multiple locale files and want to set the locale based on the URL requested you’d do this in your ApplicationController:

    before_filter :set_locale
    
    def set_locale
      I18n.locale = params[:locale] || I18n.default_locale
    end
    

    This will spare you the headache of setting locale in each controller separately. You do it once, and you have the locale set all over the system.

    Same goes for the famous protect_from_forgery which can be found on the default ApplicationController of a new rails app.

    Another use case could be rescuing all exception of a certain type in your application:

    rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
    private
    def record_not_found
      render :text => "404 Not Found", :status => 404
    end
    

    In general, if you have a feature that all other controllers would definitely use, ApplicationController might be a good place for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting into Grails having had some experience with Rails, and I
I'm just getting into Rails and I'm having some trouble understanding some syntax elements
I'm just getting into TDD with Rails. Something that is puzzling me is when
I am just getting into rails.vim as my ROR IDE and I am really
Just getting into the NoSQL stuff so forgive me if this is a simple
Just getting into SQL stored queries right now... anyway, here's my database schema (simplified
I am just getting into javascript and d3.js. Please excuse the simple question, but
I'm just getting into using REST and have started building my first app following
I am just getting into more client-side stuff in ASP.NET using Javascript, and there's
We're just getting into MVVM in WPF. We have implemented our ViewModels with 'strongly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.