In the process of writing my first Ember-app, I have not been able to figure out how to POST a new resource to my API using the REST Adapter.
The app successfully retrieves a list of resources and displays it, so it seems my Model is defined correctly and the communication between the Adapter and the API works. When I click on the CreateBugView-button, the new instance shows up in the list, so this part works as well. However, I can see in the inspector that no POST-request is made to the API and when I refresh the page, the instance is, predictably, nowhere to be seen.
I am using the 1.0.0-rc.1 version of Ember and a version of Ember Data that I cloned and built today.
Below is my code, I'd be grateful to anyone who could help me figure out what's wrong.
App = Em.Application.create()
# Templates
require 'templates/application'
require 'templates/index'
# Models
App.Bug = DS.Model.extend
name: DS.attr 'string'
# Views
App.CreateBugView = Em.View.extend
tagName: 'button'
click: (evt) ->
bug = App.Bug.createRecord
name: 'Sean'
# Routes
App.IndexRoute = Em.Route.extend
model: -> App.Bug.find()
setupController: (controller, bugs) ->
controller.set 'bugs', bugs
controller.set 'App', App
# Store
App.Store = DS.Store.extend
revision: 12
# Router
App.Router.map ->
@route 'index', path: '/'
App.initialize()
Index-template
<ul>
{{#each bugs}}
<li>{{name}}</li>
{{/each}}
</ul>
{{#view App.CreateBugView}}
Create new bug!
{{/view}}