Skip to content

Instantly share code, notes, and snippets.

View fabiokr's full-sized avatar

Fabio Kreusch fabiokr

View GitHub Profile
@fabiokr
fabiokr / rails_3_list_of_entities.rb
Created August 15, 2011 19:48
Retrieve a list of Rails 3 Controllers (or any other entities)
# Replace "app/controllers" for the kind of thing you are looking for
# A list of available items can be found in rails/railties/lib/rails/engine/configuration.rb#line39
Rails.configuration.paths["app/controllers"].expanded.inject([]) do |controllers, dir|
controllers += Dir["#{dir}/**/*_controller.rb"].map do |file|
file.gsub("#{dir}/", "")
.gsub(".rb", "")
.camelize
.constantize
end
/** SELECT VALUES FOR SECTION 'Vanity Tops' AND FILTER 'AVAILABLE_COLORS' **/
SELECT VALUE AS NAME,
VALUE AS VALUE,
Count(VALUE) AS COUNT
FROM (SELECT product_id,
VALUE,
position
FROM (SELECT pa.product_id AS product_id,
pa.position AS position,
Substr(pa.VALUE,Instr(pa.VALUE,'~') + 1,Length(pa.VALUE)) AS VALUE