Ruby Namespace
Ich bin ziemlich neu in Ruby und komme aus einem PHP-Hintergrund, aber irgendetwas passt nicht zu mir.
Angenommen, ich habe eine Ruby on Rails-Anwendung und versioniere meine API folgendermaßen:
app
|_controllers
|_api
| |_v1
| | |_application_controller.rb
| | |_user_controller.rb
| |_application_controller.rb
|_application_controller.rb
Mit der Klassenstruktur mit
# Versioned API V1 app controller
module Api
module V1
class ApplicationController
end
end
end
# Versioned API app controller
module Api
class ApplicationController
end
end
# Root app controller
class ApplicationController
end
#The code in question
module Api
module V1
class UserController < ApplicationController
end
end
end
Also die Frage ist, sucht Ruby nachApi::V1::ApplicationController
, Api::ApplicationController
, oderApllicationController
für die Verlängerung?
Nimmt das< ApplicationController
suche nach einem eigenen Namespace, wenn ich nicht @ spezifizieApi::ApplicationController
? Wenn ja, wie gebe ich den Root an?