Skip to content

Instantly share code, notes, and snippets.

@csaunders
Created September 28, 2013 13:17
Show Gist options
  • Save csaunders/6741984 to your computer and use it in GitHub Desktop.
Save csaunders/6741984 to your computer and use it in GitHub Desktop.
Why am I getting the error Uncaught TypeError: Object post has no method '_create' when trying to create a new post?
Blember.Post = DS.Model.extend
title: DS.attr('string'),
isCompleted: DS.attr('boolean')
Blember.Post.FIXTURES = [
{
id: 1,
title: 'Hello World',
body: 'This is my first post',
isCompleted: true
},
{
id: 2,
title: 'Hello Ember',
body: 'This is my first post',
isCompleted: false
}
]
Blember.PostsController = Ember.ArrayController.extend
actions:
createPost: ->
title = @get('newTitle')
return if !title.trim()
post = @store.createRecord 'post', {
title: title, isCompleted: false
}
@set('newTitle', '')
post.save()
class PostsController < ApplicationController
POSTS = [
{title: "Hello World", body: "This is a body", is_completed: true},
{title: "Another World", body: "Doodle, strudel", is_completed: false}
]
def index
respond_to do |format|
format.html
format.json {
render json: POSTS
}
end
end
def create
POSTS << params[:post]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment