Answer the question
In order to leave comments, you need to log in
How are these structures different?
There are two pieces of code:
module Admin
class CategoriesController < AdminController
class Admin::CategoriesController < ApplicationController
Answer the question
In order to leave comments, you need to log in
There are differences. In the first case, the code inside the class will see the constants from the module (and the names of nested classes, respectively), but not in the second.
Example:
module A1
TEST = 'zz'
end
module A1
class B1
def foo
TEST
end
end
end
module A2
TEST = 'zz'
end
class A2::B2
def foo
TEST
end
end
A1::B1.new.foo #> "zz"
A2::B2.new.foo #> NameError: uninitialized constant A2::B2::TEST
first google link for "rails modules": rubyclub.blogspot.ru/2012/10/ruby_869.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question