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
public class ObjectComparer : System.Collections.IComparer | |
{ | |
private const int COMPARE_EQUAL = 0; | |
private const int COMPARE_GREATERTHAN = 1; | |
private const int COMPARE_LESSTHAN = -1; | |
private string _propertyNames = string.Empty; | |
//params string[] names | |
public ObjectComparer(string propertyName){ | |
this._propertyNames = propertyName; | |
} |
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
Sequel.connect(:adapter => 'oracle', :user => 'something', :password => 'secret', :database => '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<somehost>)(PORT=<someport>))(CONNECT_DATA=(SID=<somesid>)))') |
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
# Hook our MongoMapper model into Solr | |
module MongoAdapter | |
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter | |
def id | |
@instance.id | |
end | |
end | |
class DataAccessor < Sunspot::Adapters::DataAccessor | |
def load(id) |
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
require File.join(File.dirname(__FILE__), '..', 'test_helper') | |
# See all assertions: http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/ | |
# Run all tests: rake test | |
# Run this test: ruby test/unit/ruby_test.rb | |
class RubyTest < ActiveSupport::TestCase | |
test "that true is the same as true" do | |
assert true == true |
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
class ApplicationController < ActionController::Base | |
helper :all | |
helper_method :current_user_session, :current_user | |
filter_parameter_logging :password, :password_confirmation | |
protected | |
def current_user_session | |
return @current_user_session if defined?(@current_user_session) | |
@current_user_session = UserSession.find | |
end |
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
<%= link_to @game.home_team, team_url(@game.home_team) %> |
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
require 'test_helper' | |
class GameTest < ActiveSupport::TestCase | |
test 'that a team can be assigned to the game home team' do | |
liverpool = Team.create!(:name => 'Liverpool') | |
chelsea = Team.create!(:name => 'Chelsea') | |
upcoming_game = Game.create!(:home_team => liverpool, :away_team => chelsea) | |
assert_equal upcoming_game.home_team, liverpool | |
assert_equal upcoming_game.away_team, chelsea |
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
before_filter :convert_team_name_parameters_to_models, :only => [:create, :update] | |
private | |
def convert_team_name_parameters_to_models | |
params[:game][:home_team] = Team.find_or_create_by_name(params[:game][:home_team]) | |
params[:game][:away_team] = Team.find_or_create_by_name(params[:game][:away_team]) | |
end |
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 GamesHelper | |
def friendly_team_name(team) | |
if team.nil? | |
'' | |
else | |
team.name | |
end | |
end | |
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
test 'that teams can have away games' do | |
liverpool = Team.create!(:name => 'Liverpool') | |
arsenel = Team.create!(:name => 'Arsenel') | |
liverpool_versus_arsenel = Game.create!(:home_team => liverpool, :away_team => arsenel) | |
assert liverpool.home_games.include?(liverpool_versus_arsenel) | |
assert arsenel.away_games.include?(liverpool_versus_arsenel) | |
end |