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 8056183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:37:48+00:00 2026-06-05T08:37:48+00:00

The REST API railscast has the following code example: module Api module V1 class

  • 0

The REST API railscast has the following code example:

module Api
  module V1
    class ProductsController < ApplicationController
      class Product < ::Product
        def as_json(options={})
          super.merge(released_on: released_at.to_date)
        end
      end
    end
  end
end

I’m having trouble following what:

  class Product < ::Product

…does? When I try to recreate something similar in irb I get:

module Fooirb(main):001:0> module Foobar
irb(main):002:1> class Product < ::Product
irb(main):003:2> end
irb(main):004:1> end
NameError: uninitialized constant Product
    from (irb):2:in `<module:Foobar>'
    from (irb):1

screen casts

  • 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-05T08:37:51+00:00Added an answer on June 5, 2026 at 8:37 am

    The :: token indicates a namespace, and if used without anything directly before, it accesses the top-level namespace. So for example, take this small program:

    class Bar
      def initialize
        puts "New ingot created"
      end
    end
    
    module Foo
      class Bar
        def initialize(location)
          puts "New bar built in #{location}".
        end
      end
    
      def self.new_bar(which)
        if which == :top
          Bar.new("Rubytown, USA")
        else
          ::Bar.new
        end
      end
    end
    

    If you call Foo.new_bar(:top), the message New bar built in Rubytown, USA gets printed. If instead you use, say, Foo.new_bar(:place_to_drink) it instead prints New ingot created“.

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

Sidebar

Related Questions

I am calling Assembla REST Api with basic authentication using the following code. I
I've got and rest api class that has several methods that perform http requests
I have a REST API using Django Tastypie. Given the following code The models
I have node.js REST api, which returns following object [ { word: word },
I am implementing a rest API and now I have to execute following request
I'm implementing a REST API using ASP.NET MVC, and a little stumbling block has
Spree REST API does not returns product images URLs when I request products list
I'm developing a REST api, and I'm wondering the following: I want to use
I have used Rest API facebook in my code and I want to change
I have the following REST API: POST /users/martin/notify/... The API is suppose to notify

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.