1 2 3 4
def format_category_list(categories) link_to_categories(categories.first(3)).tap do |output| if categories.size > 3 ...
1 2
uri = URI.parse(the_uri) uri.query = CGI.parse(uri.query).merge!('size' => size).map { |key,value| URI.escape("#{key}=#{value}") }.join('&')
1 2
CartItem.group(:cart_id).where('quantity > 6').sum(:quantity) # => #<OrderedHash {1=>16, 2=>12}>
1 2 3
attributes = openid_mapping.inject({}) do |hash,(key,maps)| hash.update(key => result.values_at(*maps).compact.first) end
1 2 3 4
class Item < ActiveRecord::Base belongs_to :cart belongs_to :product ...
Ruby On Add product to cart, reject...
by Adam,
August 17, 2010 00:20
Additionally, set your quan...
1
array.inject({}) { |hash,key| hash.update(key => func(key)) }
Ruby On How to make it more idiomatic?
by Adam,
August 16, 2010 23:35
True, but Hash#update is ev...
1
percentile = 1.0 / items.sum { |item| item.fragments.count } * 100
Ruby On Calculate sum of items in a...
by Adam,
August 16, 2010 19:33
ActiveSupport defines Enume...
1 2 3 4
class User delegate :name, :to => :user_group, :prefix => :user_group, :allow_nil => true ...
1 2 3 4
tab = [ ["a","b"] , ["c","e"] , ["d"]] def generate(tab) ...
Ruby On Generate code for parsing a...
by Adam,
August 11, 2010 16:23
Not sure why you are genera...
1 2
@groups = ldap.get_groups("DC=example,DC=com") @group_names = @groups.map { |group| group[:cn ] }.flatten!
1 2 3
def translated? [ params, cookies, session ].any? { |store| store[:lang] == 'en' || store[:locale] == 'en' } end
1 2 3
def is_pos_activation?(&block) session[:pos_activation] && (block || Proc.new { true }).call end
1 2 3 4
function dataStringToArray(string) { return string.split('|').map(function(segment) { return segment.split(',').map(function(digit) { ...

Good point. Like I have sai...