def has_store_url?(user)
user and \
user.respond_to?(:orders) and \
...
Ruby Existence of ActiveRecord a...
User has_many :orders, Orde...
Ruby On Handling NoMethodError
by chipcastle.myopenid.com,
August 13, 2010 19:15
Great ideas! If I'm follow...
if @user && @user.role && @user.role.eql?('user') && @user.user_group
@group_name = @user.user_group.name
end
Ruby Handling NoMethodError
by chipcastle.myopenid.com,
August 13, 2010 17:30,
4 refactorings
It seems to me that there s...
# Array of LDAP group names @group_names = [] ...
Ruby Refactor array of hashes
by chipcastle.myopenid.com,
August 09, 2010 22:44,
1 refactoring, tagged with ruby array hash flatten select
The code below gives me wha...
class Rule < ActiveRecord::Base RULE_TYPES = [:allowed_senders, :blocked_senders, :blocked_character_set, :custom] end ...
Ruby Rails helper method needs r...
There has got to be a much ...
if ($('invoice_discount')) {
this.invoice_discount = this.form.down('#invoice_discount');
this.invoice_discount.observe('change', this._checkFormat.bindAsEventListener(this));
...
JavaScript Need help with creating a loop
by chipcastle.myopenid.com,
November 01, 2009 18:37,
5 refactorings, tagged with javascript prototype
I have the following code t...
document.observe('dom:loaded', function(event) {
var MemberReviews = Class.create({
...
JavaScript Common unobtrusive javascri...
by chipcastle.myopenid.com,
October 22, 2009 13:41,
1 refactoring, tagged with javascript unobtrusive ajax prototype rails
I have this javascript patt...
@subscriptions = [:free, :lite, :brisk, :jammin].inject({}) {|result, ele| result[ele] = SubscriptionType.make(ele); result }
Ruby On Hash assignment
by chipcastle.myopenid.com,
August 04, 2009 01:42
Of course! inject is defin...
details = [{:amount=>"5.95", :subtotal=>"11.90", :menu_label=>"Grommets", :qty=>"2"},
{:amount=>"1.25", :subtotal=>"11.25", :menu_label=>"Stuff", :qty=>"9"},
{:amount=>"33.95", :subtotal=>"169.75", :menu_label=>"More Stuff", :qty=>"5"},
...
Ruby Extract specific keys from ...
by chipcastle.myopenid.com,
August 04, 2009 01:40,
3 refactorings
I would like to create an a...
zone = <<EOS
zone #{@domain} {
type master;
...
Ruby On Add zone in named.conf.local
by chipcastle.myopenid.com,
August 03, 2009 20:32
Oops, on the last one, the ...
zone = %/zone #{@domain} {\n type master;\n file #{@zone_file_name}\n};/
Ruby On Add zone in named.conf.local
by chipcastle.myopenid.com,
August 03, 2009 20:29
Does this work for you better?
@subscriptions = {}
[:free, :lite, :brisk, :jammin].each { |sub_type| subscriptions[sub_type] = SubscriptionType.make(sub_type) }
Ruby Hash assignment
by chipcastle.myopenid.com,
August 03, 2009 20:02,
8 refactorings
Here's the long way of writ...

Looking for a more concise ...