def self.categories_with_count
Category.find_by_sql("SELECT categories.name AS name, categories.slug AS slug, COUNT(categorizations.id) AS count FROM categories LEFT OUTER JOIN categorizations ON categories.id = categorizations.category_id GROUP BY categorizations.category_id, categories.name, categories.slug ORDER BY categories.name")
end
def disease_search(query)
treatment_results = Array.new
symptom_results = Array.new
...
Ruby Messy Blocks
by https://www.google.com/accounts/o8/id?id=AItOawncqSogDKAQLilNnxoB32ZKr-9LXu8x3WA,
April 06, 2011 02:50,
6 refactorings, tagged with array, rails activerecord, blocks
This is a really ugly metho...
def disease_search(query)
treatment_results = Array.new
symptom_results = Array.new
...
Ruby Messy Blocks
by https://www.google.com/accounts/o8/id?id=AItOawncqSogDKAQLilNnxoB32ZKr-9LXu8x3WA,
April 06, 2011 02:50,
4 refactorings, tagged with array, rails activerecord, blocks
This is a really ugly metho...
# In helper def show_row(label, attribute) ...
Ruby Infer column name from inst...
Assume you have a model, li...
# Associations # # User: has_many :sources, :as => :sourceable, :dependent => :destroy ...
Ruby Get child elements from a o...
by Chris,
March 11, 2010 08:27,
2 refactorings, tagged with activerecord, model, rails activerecord, assoziations
For a object (e.g. user), I...
@merged << @array1 @merged << @array2 @merged.flatten! ...
Ruby Merging two active record a...
I'm merging two active reco...
named_scope :with_description, :conditions => "description IS NOT NULL and trim(description) != ''"
Ruby Doing a 'blank?' in named_s...
Can you do a .blank? in a n...
class Car < ActiveRecord::Base belongs_to :model has_many :photos ...
Ruby DRY it up please
This is a model.
my method...
def all_shops(products)
ids = []
products.collect { |product| product.shops }.flatten.reject { |s| if ids.include?(s.id); true; else; ids.push(s.id); false; end }
...
Ruby Squash a collection.
The goal is to return a lis...
Hi!
I'm trying to retrie...