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
has_many model_B | |
before_save set_model_b_attributes | |
def set_model_b_attributes | |
self.bs.each do |b| | |
b.value = self.value | |
end | |
end |
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
param[:attribute] = true | |
# model passes validation as model.attribute = true |
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
number = rand(10) | |
puts 'Guess the number!' | |
input = 'input number' | |
while input != number | |
input = gets.to_i # keep getting more numbers | |
# give out hints to the user | |
if input > number | |
puts 'Too high' | |
end |
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
GUESS_RANGE = 100 | |
guessNumber = rand(GUESS_RANGE) | |
puts "Guess the number! (Hint: between 0 and #{GUESS_RANGE})" | |
guessCount = 0 | |
while (userGuess = gets.to_i) != guessNumber # keep getting more numbers | |
# give out hints to the user | |
puts 'Too high' if userGuess > guessNumber |
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
(function(websocketClient, $, undefined) { | |
var PING_INTERVAL = 42000, | |
RECONNECT_INTERVAL = 10000, | |
WEBSOCKET_URL = window.location.host + '/websocket'; | |
var config, reconnectInterval, keepAliveInterval, dispatcher; | |
websocketClient.init = function(websocketConfig) { | |
config = websocketConfig; | |
setupDispatcher(); | |
}; |
NewerOlder