1 2 3
class Dj < ActiveRecord::Base ...
Ruby On Password update code
by jamesgolick,
July 17, 2008 13:15
1 2 3 4
function showEMail(element) { var e = { name: 'myemail', ...
JavaScript On Anti-spam Mailto
by jamesgolick,
January 08, 2008 04:34
document.write really sucks...
Ruby On Challenge: Ugliest Ruby Fiz...
by jamesgolick,
December 20, 2007 23:55
oh my... I'd like to see so...
1 2 3 4
class Fixnum def <=>(b) self % b ...
Ruby Challenge: Ugliest Ruby Fiz...
by jamesgolick,
December 20, 2007 21:54,
8 refactorings
So, after seeing some ugly ...
1
update.failure.responds_to %(js html)
Ruby On resource_controller: Redesi...
by jamesgolick,
November 05, 2007 22:42
I love those. The *_finder ...
1 2 3
class PostsController < ResourceController::Base ...
Ruby On resource_controller: Redesi...
by jamesgolick,
November 05, 2007 20:28
First refactoring from my b...
1 2 3
class PostsController < ResourceController::Base ...
Ruby resource_controller: Redesi...
Backstory on my blog: http:...
1 2 3
ROLES = %w( administrator staff ) ...
Ruby On restful_authentication role...
by jamesgolick,
September 27, 2007 12:06
As an aside, it's helpful t...
1 2 3
def self.requires_role(role, options={}) before_filter(options) { |controller| controller.instance_eval { logged_in? && current_user.send("#{role}?") ? true : controller.access_denied } } end
Ruby On restful_authentication role...
by jamesgolick,
September 27, 2007 11:59
Marc's suggestion. Which o...
1 2 3
def self.requires_role(role, options={}) before_filter(options) { |controller| controller.send(:logged_in?) && controller.send(:current_user).send("#{role}?") ? true : controller.send(:access_denied) } end
Ruby On restful_authentication role...
by jamesgolick,
September 27, 2007 11:56
Problem is, that block seem...
1 2 3
before_filter :login_required
...
Ruby restful_authentication role...
by jamesgolick,
September 27, 2007 10:40,
7 refactorings
This is a couple of lines t...
1 2 3 4
def test_should_create_image_if_necessary_before_trying_to_give_it_data file = mock :content_type => "jpg", :size => 10, :original_filename => "something.jpg", :path => "/home" ...
1 2 3 4
def test_should_create_image_if_necessary_before_trying_to_give_it_data file = mock() file.expects(:content_type).returns('jpg') ...
1 2 3 4
def link(item, msg = nil) msg ||= item.send([:name, :title, :id].detect {|n| item.respond_to? n}) method = "#{item.class.name.underscore}_path" ...
Ruby Linking that doesn't suck a...
by jamesgolick,
September 20, 2007 08:16,
1 refactoring
Tammer Saleh, creator/maint...
1 2 3 4
class PostsController < ApplicationController make_resourceful do ...
Ruby On Typical restful scaffold co...
by jamesgolick,
September 19, 2007 13:32
Why not use make_resourceful
1 2 3 4
def cachable_time_ago_in_words(from, id_prefix = '') id = "#{id_prefix}_#{from.to_i}" content_tag :span, "", :id => id ...
Ruby On How to make time_ago_in_wor...
by jamesgolick,
September 19, 2007 13:18
But document.write is still...

Managing flow with exceptio...