This file contains 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
1. User hits a URL | |
2. Ember's Router recognizes it and passes it to a Route object | |
3. The Route sets up a Controller and supplies it with a Model | |
4. The Model provides the View layer (represented by a Template) access to the data | |
5. Any properties defined by the Model are available to the Controller | |
ex: if User has first_name, your template has direct access to it through the Controller | |
*** don't need to define an empty controller method like in Rails *** | |
*** Ember will also generate the controller for you if one does not exist *** |
This file contains 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
// in the controller | |
App.NumberController = Ember.ObjectController.extend({ | |
number: 1, | |
timesTwo: function() { | |
return Number(this.get('number')) * 2; | |
}.property('number') //tells it to treat it as a dynamic property that updates whenever number updates. | |
}); | |
//in the template | |
{{input type="text" value=number size=50}} x2 = {{timesTwo}} |
This file contains 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
App.ProfilePhotoView = Ember.View.extend({ | |
click: function(evt) { | |
this.get('controller').send('ExpandProfilePhoto'); | |
} | |
}); | |
App.UserController = Ember.ObjectController.extend({ | |
actions: { | |
expandProfilePhoto: function() { | |
//get the expanded picture and display it |
This file contains 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
App.UserController = Ember.Object.Controller.extend({ | |
fullName: function() { | |
return this.get("first_name") + " " + this.get("last_name"); | |
} | |
}) |
This file contains 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
App.UserRoute = Ember.Route.extend({ | |
model: function(params) { | |
return this.store.find(user, params.user_id); | |
} | |
)}; |
This file contains 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
#!/usr/bin/ruby1.9.1 -Kw | |
# -*- coding: utf-8 -*- | |
class Edge | |
attr_accessor :src, :dst, :length | |
def initialize(src, dst, length = 1) | |
@src = src | |
@dst = dst | |
@length = length |
This file contains 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
puts 'SONNY..? IS THAT YOU..?' | |
input1 = '' | |
bye_count = 0 | |
while bye_count < 3 | |
input1 = gets.chomp | |
if input1 == 'BYE' | |
bye_count += 1 | |
puts 'NO. NOT SINCE '+(rand(1920..1956)).to_s | |
elsif input1.upcase == input1 | |
puts puts 'NO. NOT SINCE '+(rand(1920..1956)).to_s |
NewerOlder