Reputation: 344
I have an API controller for a model in my rails project.
The API controller is as follows:
#app/controllers/api/v1/airbnb/customers_controller.rb
module Api
module V1
class CustomersController < Api::V1::BaseApiController
def create
@airbnb_customer = Airbnb::Customer.new
@json_request['airbnb_customer']['client_id'] = @client.id
update_values :@customer, @json_request['airbnb_customer']
end
end
end
end
The problem comes when creating the new airbnb_customer
:
NameError in Api::V1::Airbnb::CustomersController#create
uninitialized constant Api::V1::Airbnb::Customer
I do not know how to prevent the Api::V1 scope from being applied when calling Airbnb::Customer.new
Any help would be greatly appreciated.
My models are located in app/models/airbnb.rb
and app/models/airbnb/customer.rb
.
Upvotes: 0
Views: 55
Reputation: 622
Adding :: before Airbnb should accesses the 'root' of the namespace tree, so you should add
::Airbnb::Customer.new
Upvotes: 1