In meiner RoR3 Anwendung habe ich einen Namensraum NS1 genannt, so dass ich diese Dateisystemstruktur haben:Wie ist es möglich, die Klassenvererbung in Namespaces mit Ruby on Rails 3?
ROOT_RAILS/controllers/
ROOT_RAILS/controllers/application_controller.rb
ROOT_RAILS/controllers/ns/
ROOT_RAILS/controllers/ns/ns_controller.rb
ROOT_RAILS/controllers/ns/profiles_controller.rb
Ich möchte, dass 'ns_controller.rb' von Anwendungscontroller erbt, so in "ns_controller.rb Datei-I haben:
class Ns::NsController < ApplicationController
...
end
Ist das der richtige Ansatz? Wie auch immer, wenn ich in dieser Situation ...
In ROOT_RAILS/config/routes.rb
ich habe:
namespace "ns" do
resources :profiles
end
@profile
ein Active ist:
@profile.find(1).name
=> "Ruby on"
@profile.find(1).surname
=> "Rails"
In application_controller.rb
ich habe:
class ApplicationController < ActionController::Base
@profile = Profile.find(1)
end
In ns_controller.rb
ich habe:
class Ns::NsController < ApplicationController
@name = @profile.name
@surname = @profile.surname
end
... @name
und @surname
Variablen nicht gesetzt sind. Warum?