1 2 3 4
class AccountsController < ApplicationController layout 'application' ...
Ruby Password update code
Ruby On collecting attributes from ...
by danielharan,
June 17, 2008 13:47
While Fabien's solution doe...
1 2 3 4
def get_number_sequence(number) @sequence = %w{ 24142 15151 25232 25252 14251 23252 23242 25151 24242 24252 }[number] ... ...
Ruby On Looking for comments on sty...
by danielharan,
June 16, 2008 15:13
Can you link to information...
1 2 3 4
<% if @user.carrier? %> <li style="width:190px" id="mobile_no_div"> <%= @user.carrier.name %> <%= @user.mobile_no %> ...
1 2 3 4
def find_npa(dialed_nxx) return 819 if [ 205, 208, 210, 213, 243 ].include? dialed_nxx return 613 if [ 203, 204, 212, 216, 218 ].include? dialed_nxx ...
1 2 3 4
>> start = Time.at 0 => Wed Dec 31 19:00:00 -0500 1969 >> later = start + 60 * 60 * 2 + 60 * 3 + 1 # add 2 hours, 3 minutes and 1 second ...
1 2 3 4
# why does the alphabet include '*' anyways? (('a'..'z').to_a << '*').each do |letter| `curl|request somesite.com/search?q=#{letter} to /tmp/cache/searches/#{letter}` ...
Ruby On Can this scraper be simplif...
by danielharan,
May 31, 2008 17:27
You're mixing too many conc...
1 2 3 4
# Find all articles in the given date range based on the published_at field def self.find_archived(year, month=nil) if month.nil? ...
Ruby On Building a dynamic date range
by danielharan,
May 09, 2008 00:53
This version is a bit longe...
1 2 3 4
class Poll attr_accessor :question def initialize(question, answers=[]) ...
Ruby On Rubyize this : 6th edition
by danielharan,
May 04, 2008 00:11
System is a vile word in a ...
Ruby On Step-REST uuuuugly controller
by danielharan,
April 28, 2008 21:01
That's no longer really res...
1 2 3 4
class JobBoard < ActiveRecord::Base has_many :job_board_postings ...
Ruby Ruby has_finder on has_many ?
This smells... one of the m...
1 2 3 4
def fizz! 'fizz' end ...
Ruby On Challenge: Ugliest Ruby Fiz...
by danielharan,
December 21, 2007 15:53
No way can I compete with M...
1 2 3 4
module Wasabi module Fizzy def fizzy? ...
Ruby On Challenge: Ugliest Ruby Fiz...
by danielharan,
December 20, 2007 22:18
I was inspired by http://re...
1 2 3 4
create do before { @post.user = current_user } responds_to :html, :js do |format| ...
Ruby On resource_controller: Redesi...
by danielharan,
November 06, 2007 01:02
I prefer responds_to. Since...
1 2 3 4
class String def postal_code? self.strip =~ /^[a-z]\d[a-z][ -]?\d[a-z]\d$/i ...
Ruby On Is This String Postal?
by danielharan,
October 30, 2007 16:08
Now that I'm looking at tha...
1 2 3 4
class String def postal? self =~ /[a-zA-Z]{1}\d{1}[a-zA-Z]{1}([\x20-])*\d{1}[a-zA-Z]{1}\d{1}/ ...
Ruby On Is This String Postal?
by danielharan,
October 30, 2007 15:40
That ternary operator is no...
1 2 3 4
namespace :migrations do desc 'reverts, renames and re-executes uncommitted migrations that conflict with already committed migrations' ...
Ruby Rails migration conflict re...
Explained here: http://www....
1 2 3 4
require 'erb' class ClientMigrator def self.create(fields) ...
Ruby Dynamic migrations for rails
by danielharan,
October 12, 2007 04:27,
1 refactoring
How do you create a rails p...
1 2 3 4
if self.location_type.to_s == 'point' breaker = {'fr' => 'proximite', 'en' =>'near' }[self.lang] else ...
1 2 3 4
def remove_insults(input) %w{ stupid moron dumbass retard }.each {|insult| input.gsub!(Regexp.new(insult, true),'*' * insult.length) } input ...
Ruby On Rubyize this : 3rd edition
by danielharan,
October 11, 2007 18:38
After noticing the issue wi...

Mostly straight from a tuto...