Skip to content

Instantly share code, notes, and snippets.

View rubiety's full-sized avatar

Ben Hughes rubiety

View GitHub Profile
# MODEL
class Theater
named_scope :with_recent_comments,
:select => "*, recent_comments.created_at AS last_comment_at",
:joins => "INNER JOIN (SELECT id, entity_id, created_at FROM comments WHERE entity_type = 'Theater' ORDER by id DESC LIMIT 100)
AS recent_comments ON recent_comments.entity_id = theaters.id",
:order => "recent_comments.created_at DESC"
end
# MODEL
class Theater
named_scope :with_recent_comments,
:select => "*, recent_comments.created_at AS last_comment_at",
:joins => "INNER JOIN (SELECT id, entity_id, created_at FROM comments WHERE entity_type = 'Theater' LIMIT 100)
AS recent_comments ON recent_comments.entity_id = theaters.id",
:order => "recent_comments.created_at DESC"
end
@rubiety
rubiety / web_services.md
Created April 12, 2011 19:17 — forked from ryanb/web_services.md
Web Services to Recommend

Different services I can suggest when a non-tech friend or family member asks me how they can cheaply make a website and possibly use it to sell stuff online.

Website Hosting

@rubiety
rubiety / gist:29404
Created November 26, 2008 14:35 — forked from qrush/gist:29315
# If you ever needed an array of all ActiveRecord models in your Rails app (+ Session):
Dir["app/models/**/*.rb"].each {|r| require r}
subclasses_of(ActiveRecord::Base).map(&:class_name)
# Or *all* models:
ActiveRecord::Base.connection # Preloads driver constants
constants_before = Object.constants
Dir["app/models/**/*.rb"].each {|r| require r}
Object.constants - constants_before
@rubiety
rubiety / gist:5426
Created August 14, 2008 13:27 — forked from qrush/gist:5425
#############################################################
# Application
#############################################################
set :application, "" #your app's name here
set :server_ip, "" #your server's ip here
set :deploy_to, "/home/rails/#{application}" #the path to your rails app here
#############################################################
# Servers