API Path Configuration Issue
I’m working through the Super-Rentals Ember.js tutorial and downloaded the complete project from the official repository. I’m having trouble figuring out how the application knows to fetch data from the rentals.json file located in the /public/api directory.
When I rename the rentals.json file to something else, the entire application breaks and won’t load any data. This tells me there’s some configuration that specifically looks for this filename.
I’ve searched through all the files in the /app folder looking for any reference to “rentals” but none of the results seem to be related to the API path configuration.
My question is: Does Ember.js use some kind of naming convention to automatically find this JSON file, or is there a specific place in the code where this API endpoint is defined? I can’t seem to locate where this connection is made.
Any help understanding how Ember handles these API paths would be great!
Ember Data handles this through its adapter system and naming conventions. The default JSONAPIAdapter pluralizes model names to build endpoint URLs - so your ‘rental’ model automatically hits ‘/rentals.json’. If you don’t have a custom adapter, Ember uses these default conventions. The buildURL() method in the adapter does the heavy lifting here. Want to change it? Create an application adapter at /app/adapters/application.js and customize the pathForType method, or make a rental-specific adapter. When you rename stuff and everything breaks, it’s because the adapter is still trying to reach the original endpoint based on those naming conventions.
hey, just took a look at your issue! u should check the /app/routes folder for the script calling findAll('rental') - that’s where the action is. Ember Data automatically pluralizes the model name and adds .json, so rental becomes rentals.json. no config is needed unless u change it in an adapter.
Ember.js doesn’t define API endpoints in one specific place - it uses convention-based routing through Ember Data. When you call this.store.findAll('rental') in your route, Ember Data builds the API path from your model name. So a ‘rental’ model automatically hits /rentals.json. Want to change this? Override the urlForFindAll method in your adapter or create a model-specific adapter. You can also tweak the host and namespace properties in your adapter to change the base API path. Check your /app/adapters folder for any existing configs that might affect this.