REST API railscast 具有以下代码示例:
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
我无法遵循以下内容:
class Product < ::Product
...做?当我尝试在 irb 中重新创建类似的东西时,我得到:
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