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
| 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 |
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
| 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 |
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
| module ActiveRecord | |
| module Searchable | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end | |
| module ClassMethods | |
| def searchable_on(*args) | |
| args.flatten! | |
| @args = args.compact |
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
| { | |
| :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 |
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
| #!/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]) |
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
| new_image = Magick::Image.new(new_image_cols, new_image_rows) { | |
| self.background_color = params[:background_color] | |
| self.format = 'png' | |
| } |
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
| [1,2,3].each do |num| | |
| puts num | |
| end; nil |
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
| 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 |
OlderNewer