Last active
December 21, 2015 05:29
-
-
Save alexspeller/6257579 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyAdapter = Ember.RESTAdapter.extend | |
| didSaveRecord: (record, data) -> | |
| rootKey = Em.get(record.constructor, 'rootKey') | |
| primaryKey = Em.get(record.constructor, 'primaryKey') | |
| dataToLoad = if rootKey then data[rootKey] else data | |
| if dataToLoad | |
| record.load(dataToLoad[primaryKey], dataToLoad) | |
| record.didSaveRecord() | |
| App.Book.adapter = MyAdapter.create() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # On server | |
| def update | |
| book = Book.find params[:id] | |
| if book.update_attributes params | |
| render json: book | |
| else | |
| raise "didn't save book" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment