How is it possible the class inheritance in namespaces using Ruby on Rails 3?
- by user502052
In my RoR3 application I have a namespace called NS1 so that I have this filesystem structure:
ROOT_RAILS/controllers/
ROOT_RAILS/controllers/application_controller.rb
ROOT_RAILS/controllers/ns/
ROOT_RAILS/controllers/ns/ns_controller.rb
ROOT_RAILS/controllers/ns/names_controller.rb
ROOT_RAILS/controllers/ns/surnames_controller.rb
I wuold like that 'ns_controller.rb' inherits from application controller, so in 'ns_controller.rb' file I have:
class Ns::NsController < ApplicationController
...
end
Is this the right approach? Anyway if I have this situation...
in 'application_controller.rb'
class ApplicationController < ActionController::Base
@profile = Profile.find(1)
end
in 'ns_controller.rb'
class Ns::NsController < ApplicationController
@name = @profile.name
@surname = @profile.surname
end
... '@name' and '@surname' variables are not set. Why?