1 2 3 4
@feedbacks.each do |feedback| data.each do |key,value| question = feedback.send("question#{key + 1}") ...
1 2 3 4
module Enumerable # Ruby 1.8.7 introduces group_by, but the result isn't ordered. Override it. remove_method(:group_by) if [].respond_to?(:group_by) && RUBY_VERSION < '1.9' ...
1 2 3 4
class Summary < Struct.new(:klass, :options) def range options[:range] || options[:from]..options[:to] ...
Ruby On Rails Active Record Time Su...
by Adam,
September 03, 2008 16:21
This is completely untested...
1 2 3 4
task :status_codes do require 'action_controller/status_codes' include ActionController::StatusCodes ...
1 2 3 4
class Commentor def comment_type self.class.to_s.downcase ...
Ruby On Too many assignments and co...
by Adam,
August 29, 2008 21:03
I couldn't quite discern wh...
1 2 3 4
def test_web_browser %w(Firefox/3 Firefox/2 MSIE\ 6 MSIE\ 7 Opera).detect do |agent| request.user_agent =~ Regexp.new(agent) ...
Ruby On Code to detect the web browser
by Adam,
August 28, 2008 22:02
@Nicolás - I don't think th...
1 2 3 4
def test_web_browser catch(:match) do ["Firefox/3", "Firefox/2", "MSIE 6", "MSIE 7", "Opera"].each do |ua| ...
1 2 3
<span class="bluelinks-allsmall"> <% if user.normal? %> ...
Ruby On Link to if else simple cond...
by Adam,
August 20, 2008 13:51
You should be using named r...
1 2 3 4
def sort(array) array.inject([]) do |sorted,element| small, large = sorted.partition { |item| item < element } ...
1 2 3 4
def self.favorite?(object) if reflection = object.class.reflect_on_association(:favorites) send("find_by_#{reflection.primary_key_name}", object) ...
1 2 3
class Report < ActiveRecord::Base %w[hits uniques].each { |const| const_set(const.upcase, const) } end
