app = App.new do
  get do
    "hi"
...

Ruby On Very Simple Rack framework

by Dan Kubb, September 14, 2008 18:48

What about being able to ne...

63b22ac9bff0cd55d8a91da4dbf00693 Talk
def self.valid?(key)
  return false unless h = find_by_key(key)
  h.invitation_details_count < h.total
...

Ruby On Better Nest Ifs

by Dan Kubb, April 13, 2008 04:26 Star_fullStar_fullStar_full

This refactoring uses a gua...

63b22ac9bff0cd55d8a91da4dbf00693 Talk
def create
  subscribers = []
  params[:recipients].to_s.each_line do |line|
...

Ruby On Importing large collection ...

by Dan Kubb, March 22, 2008 21:31 Star_fullStar_fullStar_fullStar_fullStar_full

Here is how I would write t...

63b22ac9bff0cd55d8a91da4dbf00693 Talk
def squarebutton(name, options = {}, html_options = {})
  html_options[:class] = [ html_options[:class], 'squarebutton' ].compact * ' '
  link_to content_tag(:span, name), options, html_options
...

Ruby On Adding default html option ...

by Dan Kubb, February 29, 2008 17:17 Star_fullStar_fullStar_fullStar_fullStar_full

This will add the "squarebu...

63b22ac9bff0cd55d8a91da4dbf00693 Talk
before_save :titlecase_fields

def titlecase_fields
...

Ruby On ActiveRecord Attributes rej...

by Dan Kubb, February 28, 2008 18:22 Star_fullStar_fullStar_fullStar_fullStar_full

This iterates over just the...

63b22ac9bff0cd55d8a91da4dbf00693 Talk
[ :planned, :actual ].each do |type|
  define_method("#{type}_percent_complete") do
    return 0 if send("#{type}_complete_in_dollars").nil?
...

Ruby On Same methods, different Act...

by Dan Kubb, January 08, 2008 20:06 Star_fullStar_fullStar_fullStar_full

Here's an alternate approac...

63b22ac9bff0cd55d8a91da4dbf00693 Talk
class String
  def postal?
    self.strip.upcase =~ /\A[A-CEGHJ-NPR-TVXY]\d[A-CEGHJ-NPR-TV-Z][ -]?\d[A-CEGHJ-NPR-TV-Z]\d\z/
...

Ruby On Is This String Postal?

by Dan Kubb, December 02, 2007 16:29 Star_fullStar_fullStar_fullStar_full

According to http://en.wiki...

63b22ac9bff0cd55d8a91da4dbf00693 Talk