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
over = { | |
amount: 20, | |
ready: true, | |
anim: function(dir, el) { | |
amount = dir * this.amount; | |
if (this.ready) { | |
this.ready = false; | |
el.animate({ | |
left: '+=' + amount, | |
top: '+=' + amount |
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
animation = { | |
amount: 20, | |
ready: true, | |
anim: function(dir, el) { | |
amount = dir * this.amount; | |
if (this.ready) { | |
this.ready = false; | |
el.animate({ | |
left: '+=' + amount, | |
top: '+=' + amount |
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
#Trying to have my root behave like my timers controller, | |
#so I wouldn't have to prefix everything with 'timers/' in the URLs | |
#resources :timers | |
root to: "timers#index", as: :timers | |
match '/:id' => 'timers#show', as: :timer | |
match '/new' => 'timers#new', as: :new_timer | |
# When I do this: |
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
source 'http://rubygems.org' | |
gem 'rails', '3.1.1' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'sqlite3' | |
gem 'mysql2' |
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
#relevant controller | |
def show | |
@timer = Timer.find(params[:id]) | |
respond_to do |format| | |
format.html | |
format.js { render layout: false } | |
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
#timers_helper.rb | |
module TimersHelper | |
def seconds_left | |
[(@timer.target - Time.now).round, 0].max | |
end | |
end | |
#timers_controller.rb | |
def refresh |
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
#Should this not cause my record to be deleted after I update it? Doesn't seem to work for me.. | |
class Timer < ActiveRecord::Base | |
after_save :destroy_timer | |
private | |
def destroy_timer | |
self.destroy | |
end | |
end |