I’m trying to develop a plugin and save records to the store (as described in Upgrading our front end models to use a store). I can create the record successfully, call save(), but it will only return a 404 at /routes.
I seem to be missing some sort of model for the type of record I want to store. Without the model below, the POST request to routes isn’t sent out. Implementing the model on my own, the request is sent, but returns a 404. I don’t know what is necessary for it to work properly. It looks like this:
By default, when you call save on your model, it’ll make a POST to /<recordname>.
I tried your example code and it seems that route is a reserved name, so I would recommend you use a different name.
Did you implement a server side route for your record to save to? For example a type of widget would save to /widgets as a POST. You can run rake routes on the command line to see the routes you’ve created.
In the meantime, I learned a couple of things. I neither have a background in any kind of back end programming nor do I know Ruby/Rails/Ember. That’s why when writing my observations, there wasn’t any server-side controller answering the requests. I managed to implement working data transfer between the client and the server as I need it.
I am able to use routes as an endpoint (i.e. I’m doing this.store.createRecord('route', ...) and requests are being sent to /routes, /routes/:route_id, etc.). Though from what you say, it sounds logical to use a different name for the endpoint, right?
Maybe I should write a tutorial on implementing basic data exchange using the store (is there a better name for that?) for transferring data between client and server and PluginStore for transferring data between application and persistent storage. That might be helpful for a few people.
Your code is likely working because you defined a new route class, but that is a conflict with Ember’s route and setting yourself up for weird errors in the future. I highly recommend you use a different name for your model/endpoint.