This file contains hidden or 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
def answer_iucu_challenge(question) | |
case question | |
when /what year/: return "1988" | |
when /what street/: return "Main Street" | |
when /father\'s middle name/: return "Jonathan" | |
when /what city/: return "Denver" | |
else "blah" | |
end | |
end | |
This file contains hidden or 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
class Model extends Spine.Model | |
# This one always pulls the data from the server. | |
@fetchAndThen: (id, callback) -> | |
@fetch(id: id) | |
@one 'refresh', (docs) -> callback(docs[0]) | |
# This one pulls the data from the server if it isn't cached locally. | |
@remoteFind: (id, callback) -> | |
if @exists? id | |
callback @find(id) |
This file contains hidden or 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.Document = DS.Model.extend | |
# some attributes here... | |
saveWhenDirty: (-> | |
@get('store').commit() if @get('isDirty') | |
).property('isDirty') |
This file contains hidden or 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.debounce = (func, wait) -> | |
timeout = null | |
-> | |
context = this | |
args = arguments | |
immediate = true if args[0] and args[0].now | |
later = -> |
This file contains hidden or 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.DocumentController = Ember.ObjectController.extend | |
autoSave: (-> | |
@debouncedSave() | |
).property('content.body') | |
debouncedSave: App.debounce (-> @save()), 1000 | |
save: -> | |
@get('store').commit() |
This file contains hidden or 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
#= require ./debounce | |
BUFFER_DELAY = 1000 | |
App.AutoSaving = Ember.Mixin.create | |
# Setup buffers to write to instead of directly editing | |
# the model attributes. | |
_buffers: Ember.Map.create() | |
# Buffered fields are saved after the set delay for the |
This file contains hidden or 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.DocumentController = Ember.ObjectController.extend App.AutoSaving, | |
bufferedFields: ['title', 'body'] | |
instaSaveFields: ['postedAt', 'category'] |
This file contains hidden or 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
s = Student.find_by(email: '[email protected]') |
This file contains hidden or 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
# Before | |
def show | |
if current_user.is_admin? | |
if params[:assignment].nil? | |
@assignments = Assignment.all | |
else | |
@assignments = Assignment.where(:student_id => params[:assignment][:id] ) | |
end | |
else |
This file contains hidden or 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
# Before | |
def index | |
if current_user.is_student? | |
@assignments = current_user.assignments.order(created_at: :desc) | |
render "student_index" | |
elsif current_user.is_admin? | |
@current_student = params[:student] | |
@students = User.get_all_students | |
@average_grade = 0 |
OlderNewer