I am implementing an API in Rails 3, and noticed an example controller defined like class Api::ToursController < ApplicationController. Does anyone know what the to colons indicate? Is it inheritance? Or is it indicating extending the ToursController? I have tried searching for an answer, but have not come up with anything.
Here is what I am referencing: https://github.com/nesquena/rabl/wiki/Set-up-rabl-for-Ruby-on-Rails
::is the scope resolution operator (i.e. namespace operator) in many languages, including C++ and Ruby, so it’s not specific to Rails.In Ruby, modules define namespaces, so you can see code like this:
Which calls the
getclass method on theHTTPclass in theNetmodule.In Rails, namespaces allow you to better organize your code (e.g. to separate your API controllers from the rest), and are implemented as modules.