Skip to content

Instantly share code, notes, and snippets.

View joshnabbott's full-sized avatar

Josh N. Abbott joshnabbott

  • Cloudflare Past:Area 1 Security, Big Cartel, Kajabi, Factory Design Labs, Oakley
  • Albuquerque, NM
View GitHub Profile
describe "named_scopes" do
it "should include one that returns products where active = true" do
create_product(:active => true)
Product.active.count.should == 1
Product.active.map(&:active).should_not include(false)
end
it "should include one that returns styles where display_only = true" do
create_product(:display_only => true)
Product.display_only.count.should == 1
task :export do
require 'sequel'
require 'fastercsv'
db = Sequel.connect(ENV['DATABASE_URL'])
table_name = ENV['table'].to_sym
table = db[table_name]
fields = table.first.keys
module ActiveRecord
module Searchable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def searchable_on(*args)
args.flatten!
@args = args.compact
{
:a => 2,
# NOTE for partials, you need to include the format
# otherwise, it'll fail to find byows/_byow.erb even if byows/_byow.html.erb exists
:b => render(:partial => 'example.html')
}.to_json
We couldn’t find that file to show.
We couldn’t find that file to show.
#!/usr/bin/env ruby
require 'yaml'
if ARGV.size < 1
puts "Usage: github-test.rb my-project.gemspec"
exit
end
require 'rubygems/specification'
data = File.read(ARGV[0])
new_image = Magick::Image.new(new_image_cols, new_image_rows) {
self.background_color = params[:background_color]
self.format = 'png'
}
[1,2,3].each do |num|
puts num
end; nil
user_controller.rb
def show
respond_to do |format|
format.json { render :json => @user.to_json(:methods => [:avatar_url])}
end
end
user.rb
def avatar_url