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

  • SEARCH
  • Home
  • 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 9198299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:15:15+00:00 2026-06-17T22:15:15+00:00

I am looking at a sample Rails application and see some strange things. Well

  • 0

I am looking at a sample Rails application and see some strange things. Well just strange to me because my past experience was with C#.

So in the ApplicationController I have a “private” method like this:

 private

    def current_cart 
      Cart.find(session[:cart_id])
    rescue ActiveRecord::RecordNotFound
      cart = Cart.create
      session[:cart_id] = cart.id
      cart
    end

and then in orders_controller class I have another method that in its body it is saying something like:

def new
   @cart = current_curt
// ....
end

What happened ? It was private but we can access it? And we don’t need to create an instance of it before accessing it ? Can someone talk a little bit about how the methods in controllers work together in Rails?

  • 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-17T22:15:16+00:00Added an answer on June 17, 2026 at 10:15 pm

    There is an instance of the controller, instantiated by the framework, per-request.

    And yes, subclasses can access the method (as running it would show).

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

Sidebar

Related Questions

A sample application I was looking at has this in environment.rb : config.gem 'rails'
I'm looking to write a sample application speaking to a POP3/SMTP server. Instead of
I am looking for some adequately-complex sample database schemas that I could use for
I am looking for suggestions on database design for a sample jobs listing application.
In some of the audio libraries I've been looking at, a sample of audio
I have a rails app running on Heroku. I am using paperclip for some
I've just started to write an application using the latest version of Rails and
I am working on a Ruby on Rails 3 web application. I have a
I have a rails application that I am trying to integrate devise_invitable into. So,
I need to implement some search functionality within a Rails application. Most of the

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.