This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |