Backbone.js on Rails @ #rcne2011
Nick Gauthier's presentation from Baltimore.rb
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
namespace :myapp do | |
task :renew => %w{db:drop db:create db:migrate} | |
end |
require 'spec_helper' | |
describe User do | |
describe "Object Attributes" do | |
before(:each) { @obj = User.new } | |
specify { @obj.should respond_to(:first_name) } | |
specify { @obj.should respond_to(:last_name) } | |
specify { @obj.should respond_to(:login) } | |
end |
class Hour < ActiveRecord::Base | |
belongs_to :user | |
validates_with PunchclockValidator #defined in config/initializers/punchclock_validator.rb | |
validates_presence_of :role, :message => "can't be blank" | |
validates_associated :user | |
validates_numericality_of :manual, :allow_nil => true | |
validates_presence_of :start_time, :if => :punchcard? | |
validates_presence_of :manual, :if => :manual? | |
end |
Feature: A user can punch in and out | |
In order to log hours | |
As an employee | |
I want to be able to punch in and punch out | |
Background: | |
Given the following user exists: | |
| name | email | password | role | | |
| foo | [email protected] | please | Employee | | |
And I log in as "[email protected]/please" |
class Hour < ActiveRecord::Base | |
belongs_to :user | |
validates_with PunchcardValidator #defined in config/initializers/punchclock_validator.rb | |
validates_presence_of :role, :message => "can't be blank" | |
validates_associated :user | |
validates_numericality_of :manual, :allow_nil => true | |
validates_presence_of :start_time, :if => :punchcard? | |
validates_presence_of :manual, :if => :manual? | |
// Set up the events for the form | |
form | |
.submit(function() { return form.isValid(settings.validators); }) | |
// added loading toggle to handle the feedback spinner image (and changed 'beforeSend' to just 'before') | |
.bind('ajax:before', function() { $("#loading").toggle(); return form.isValid(settings.validators); }) | |
.bind('ajax:success', function() { $("#loading").toggle(); }) | |
// Callbacks | |
.bind('form:validate:after', function(eventData) { clientSideValidations.callbacks.form.after( form, eventData); }) | |
.bind('form:validate:before', function(eventData) { clientSideValidations.callbacks.form.before(form, eventData); }) |
Backbone.js on Rails @ #rcne2011
Nick Gauthier's presentation from Baltimore.rb
require 'benchmark' | |
def ifelse | |
if true | |
1 | |
else | |
2 | |
end | |
end |
require 'uri' | |
class IoraBot::Hangout < IoraBot::Observer | |
def matcher | |
/^(hangout|standup)(.*)$/mi | |
end | |
def handle(message, match_data) | |
person = message[:user][:name].split(' ')[0] | |
command = match_data[1] | |
if command == 'standup' | |
reply = "All: time for standup: #{link('iora_standup')}" |