Skip to content

Instantly share code, notes, and snippets.

View amatsuda's full-sized avatar

Akira Matsuda amatsuda

View GitHub Profile
products = Product.where("price = 100").limit(5) # No query executed yet
products = products.order("created_at DESC") # Adding to the query, still no execution
products.each { |product| puts product.price } # That's when the SQL query is actually fired
class Product < ActiveRecord::Base
scope :pricey, where("price > 100")
scope :latest, order("created_at DESC").limit(10)
end
@amatsuda
amatsuda / rspec.vim
Created July 31, 2009 11:00 — forked from moro/rspec.vim
function! s:RunRspec (opts)
let rails_spec_path_re = '\<spec/\(models\|controllers\|views\|helpers\)/.*_spec\.rb$'
if( expand('%') =~ rails_spec_path_re && filereadable('script/spec') )
"let command = '!ruby script/spec '
let spec_command = '!rspec '
if filereadable('tmp/pids/spec_server.pid')
let spec_command = spec_command . ' --drb '
endif
else