Skip to content

Instantly share code, notes, and snippets.

View endash's full-sized avatar

Christopher Swasey endash

View GitHub Profile
model: function () {
var route = this;
return this.get('store').findAll('lens').then(function (lenses) {
route.transitionTo('lens', lenses.get('firstObject'));
});
},
App.Router.map(function() {
...
this.resource('lenses', function(){
this.route('index');
this.resource('lens', {path: '/:lens_id'}, function() {
this.route('technical_data');
this.route('grids');
this.route('angles_of_view');
});
});
gem "ember-source", :git => 'https://github.com/emberjs/ember.js.git', :ref => '8b14532a3784ff467259a5a88a249a1283b9b47e'
gem "handlebars-source", "~> 1.3.0"
gem 'ember-rails'
App.Router.map(function() {
this.route('sign_in');
this.resource("calendar", function () {
this.resource("calendar_month", {path: 'month'}, function () {});
this.resource("calendar_week", {path: 'week'}, function () {});
this.resource("calendar_day", {path: 'day'}, function () {});
})
});
$scope.$watch('[min, max]', function (vals) {
var min = vals[0], max = vals[1], date = $scope.date;
var start = moment(date),
end = moment(date);
start.hour(min/60);
start.minute(min % 60);
end.hour(max/60);
this.resource("artists", function () {
this.route("index");
this.resource("artist", {path: "/artists/:id"}, function () {
this.route('index');
this.resource("albums", function () {
this.route("index");
this.resource("album", {path: "/albums/:id"}, function () {
this.route('index');
this.resource("tracks", function () {
this.route('index');
facebook: function () {
var route = this;
FB.login(function (response) {
if (response.authResponse) {
var session = route.controllerFor('session');
session.set('facebookAccessToken', response.authResponse.accessToken)
session.save().then(function () {
route.transitionTo('calendar_month')
});
}
ModelProxy = Ember.Object.extend(Ember.Validations.Mixin, Ember.ActionHandler, {
init: function() {
this.props = {};
this._super.apply(this, arguments);
},
autosave: false,
content: null,
// This is a disaster, thanks mostly to jquery-file-upload
App.FileUploadView = Ember.View.extend({
templateName: 'file_upload_view',
tagName: 'form',
classNames: ['file-upload-view', 'clearfix'],
attributeBindings: ['action', 'method', 'enctype'],
// action: "http://my_bucket.s3.amazonaws.com/",
action: null,
method: "POST",

Idle Reminiscing (on Rails)

Rails, in 2007, was a tall glass of cold water. Coming from a world of spaghetti-coded PHP scripts (if you were lucky—ColdFusion, Java, or ASP if you weren't) it seemed to be the right framework at the right time: the router took away the jumble of scripts that hard-coded our app endpoints, the "MVC" structure and naming conventions fit all of our code into nice, individually labeled bins, and ActiveRecord single-handedly eliminated 99% of the reams of hand-coded, error-prone, wildly insecure SQL that littered our codebases.

In time, though, it's become more and more clear that Rails was simply a framework at the right time. Rails didn't impose a new object-oriented structure on our previously formless apps... it simply imposed a new Railsy structure, and obscured the difference with a language change. If a block of code went at the top of a PHP file, that same chunk of code, transmogrified, got stuck into the controller, by default, because that was the first point o