This file contains 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
# undefined method `should_respond_with' for #<UserSessionsController> | |
require 'test_helper' | |
class UserSessionsControllerTest < ActionController::TestCase | |
should_have_before_filter :require_no_user, :only => [:new, :create] | |
should_have_before_filter :require_user, :only => :destroy | |
This file contains 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
# Controller | |
def index | |
@results = SexOffender.all | |
end | |
# View | |
<% if @results.blank? %> | |
<span>no sex offenders were found</span> |
This file contains 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 Order < AR:Base | |
has_one :credit_card_payment | |
has_one :paypal_express_payment | |
has_one :horse_shoe_payment | |
validates_presence_of :payment_type, :in => [:credit_card_express, :paypal_express, :horse_shoe] | |
def payment_proxy |
This file contains 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
validates_presence_of :number, :description | |
validates_uniqueness_of :number | |
has_and_belongs_to_many :alternates, :class_name => 'PartNumber', | |
:join_table => 'alternate_part_numbers', | |
:foreign_key => 'part_number_id', | |
:association_foreign_key => 'alternate_part_number_id' | |
has_and_belongs_to_many :alternate_for, :class_name => 'PartNumber', | |
:join_table => 'alternate_part_numbers', | |
:foreign_key => 'alternate_part_number_id', |
This file contains 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 PartNumberTest < ActiveSupport::TestCase | |
should_have_and_belong_to_many :alternates | |
should_have_and_belong_to_many :alternate_for | |
should_validate_presence_of :number | |
should_validate_presence_of :description | |
should_validate_uniqueness_of :number |
This file contains 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
OAuth::Consumer.class_eval do | |
def get_request_token(request_options = {}, *arguments) | |
response = token_request(http_method, (request_token_url? ? | |
request_token_url : request_token_path), nil, request_options, | |
*arguments) | |
OAuth::RequestToken.from_hash(self, response) | |
end | |
end |
This file contains 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
## on part.rb | |
# i use pn as a virtual attribute. | |
def pn=(part_number) | |
@part_number = PartNumber.find_by_number(part_number) | |
logger.info "NEW PART NUMBER " | |
if @part_number.blank? | |
#self.part_number_id = PartNumber.create(:number => part_number, :description => 'none').id | |
self.build_part_number(:number => part_number, :description => 'no description') |
This file contains 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
## controller | |
Company.search({:warehouses_parts_quantity_greater_than => 0}).all | |
## error | |
ActiveRecord::ConfigurationError: Association named 'condition' was not found; perhaps you misspelled it? | |
## Models | |
Company has many warehouses, | |
Warehouse has many parts |
This file contains 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
## source | |
<table class="table"> | |
<thead> | |
<tr> | |
<th>Part Number</th> | |
<th style="width:70px;">Quantity</th> | |
<th>Condition</th> | |
<th style="width:70px;">Price</th> | |
<th></th> |
This file contains 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
|app/controllers/users_controller.rb | 42 | 36 | 25.0% | |