Skip to content

Instantly share code, notes, and snippets.

@devsergiy
Forked from ivanvanderbyl/account_routes.js
Created November 21, 2013 10:06
Show Gist options
  • Select an option

  • Save devsergiy/7579055 to your computer and use it in GitHub Desktop.

Select an option

Save devsergiy/7579055 to your computer and use it in GitHub Desktop.

Revisions

  1. @ivanvanderbyl ivanvanderbyl revised this gist Jan 17, 2013. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions index.html.haml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    %noscript
    .container
    .alert
    %strong
    Javascript is disabled!
    The AppName UI is built entirely in Javascript, as such you need to enable
    Javascript in your browser to continue.

    :javascript
    var currentUser = jQuery.parseJSON('#{current_user_json}');
  2. @ivanvanderbyl ivanvanderbyl created this gist Jan 17, 2013.
    5 changes: 5 additions & 0 deletions account_routes.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    App.AccountEditRoute = Ember.Route.extend({
    setupController: function(controller) {
    controller.set('content', this.get('currentUser'));
    }
    });
    21 changes: 21 additions & 0 deletions injections.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    Ember.Application.initializer({
    name: "currentUser",

    initialize: function(container, application) {
    var store = container.lookup('store:main');
    var obj = store.load(CrashLog.User, currentUser);

    container.optionsForType('user', { instantiate: false, singleton: true });
    container.register('user', 'current', CrashLog.User.find(obj.id));
    }
    });

    Ember.Application.initializer({
    name: "injectCurrentUser",
    after: 'currentUser',

    initialize: function(container) {
    container.injection('controller:application', 'currentUser', 'user:current');
    container.typeInjection('route', 'currentUser', 'user:current');
    }
    });