Skip to content

Instantly share code, notes, and snippets.

// store.js
App.Adapter = DS.RESTAdapter.reopen({
bulkCommit: false,
url: 'http://localhost:5000',
namespace: 'api',
corsWithCredentials: true,
headers: {
'Accept': 'application/vnd.vendor+json;version=1',
'Content-type': 'application/json',
// store.js
var serializer = DS.RESTSerializer.create();
App.Adapter = DS.RESTAdapter.reopen({
bulkCommit: false,
serializer: serializer,
});
serializer.configure({
{{view Ember.TextField
valueBinding="storeCard.relevantDate"
classNames="timepicker-default input-small"
}}
<span class='add-on'><i class="icon-time"></i></span>

I've been trying to do routing in Ember using something other than id. This is how I implemted a dasherized version of a post's title. I get the feeling that instead of the deserialize function I should be overwrite the model function as the guides suggest, but then I lose the symmetry I have with the serialize function.

If there's a better/more ember way, I'd love to know.

Thanks @darthdeus for teaching me about DS.LoadPromise

@boy-jer
boy-jer / route.js
Created April 24, 2013 20:05 — forked from darthdeus/route.js
Scvrush.UserEditRoute = Ember.Route.extend({
events: {
saveProfile: function() {
var user = this.controllerFor("user").get("content"),
route = this;
user.one("didUpdate", function() {
route.transitionTo("home");

Rollback a transaction when user exits a route

I just stubmled upon an issue in my app where a user can go to edit his profile, but instead of saving the form he just leaves to another page where he can post a status (User has many Statuses).

But to make sure that he's just posting a status and not committing something else I want to put that status into a separate transaction

createStatus: function() {
  var transaction = this.get("store").transaction(),
      text = this.get("text"),

Rollback a transaction when user exits a route

I just stubmled upon an issue in my app where a user can go to edit his profile, but instead of saving the form he just leaves to another page where he can post a status (User has many Statuses).

But to make sure that he's just posting a status and not committing something else I want to put that status into a separate transaction

createStatus: function() {
  var transaction = this.get("store").transaction(),
      text = this.get("text"),
authenticated :user do
root to: "agendas#show"
end
unauthenticated :user do
devise_scope :user do
root to: "devise/sessions#new"
end
end
template = template.replace(/@(\w+)/, "{{view Scvrush.UserLinkView username='$1'}}");
usernames = template.match(/@(\w+)/);
controllerFor('controllerWithText').set('usernames', usernames);
Scvrush.ControllerWithText = Em.Controller.extend({
init: function() {
var usernames = this.get('usernames'),
loadedusers = Scvrush.User.all();
App.PostsController = Em.ArrayController.extend({
page: 1,
content: function loadPosts() {
return App.Post.filter({page: 1}, function() {});
}.property(),
loadMore: function() {
App.Post.find({page: this.incrementProperty('page')})
}