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
| #In case it wasn't obvious, this was a joke about Rails anti-patterns | |
| def address(separator, seperator2=' ') | |
| fields_array = %w(address1 address2 city state zip phone).map {|t| [:billing,t].join('_').to_sym} | |
| (0..10).inject("") { |string, i| | |
| if i.odd? | |
| field = :separator | |
| field = (field.to_s + '2').intern if i == 7 | |
| else | |
| field = fields_array[i/2] | |
| 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
| def address(separator, seperator2=' ') | |
| fields_array = %w(address1 address2 city state zip phone).map {|t| [:billing,t].join('_').to_sym} | |
| (0..10).inject("") { |string, i| | |
| if i.odd? | |
| field = :seperator | |
| field = (field.to_s + '2').intern if i == 7 | |
| else | |
| field = fields_array[i/2] | |
| end | |
| temp = send(field) rescue 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
| def address(separator, seperator2=' ') | |
| fields_array = [:billing_address1, :billing_address2, :billing_city, :billing_state, :billing_zip, :billing_phone] | |
| (0..10).inject("") { |string, i| | |
| if i.odd? | |
| field = :seperator | |
| field = (field.to_s + '2').intern if i == 7 | |
| else | |
| field = fields_array[i/2] | |
| end | |
| temp = send(field) rescue 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
| def address(separator) | |
| "#{billing_address1}#{separator}#{billing_address2}#{separator}#{billing_city}#{separator}#{billing_state} #{billing_zip}#{separator}#{billing_phone}" | |
| 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
| require "test_helper" | |
| require "yaml" | |
| class FixtureTest < ActiveSupport::TestCase | |
| fixtures :all | |
| Dir[File.join Rails.root, "test", "fixtures", "**", "*.yml"].each do |file| | |
| if fixtures = YAML.load(IO.read(file)) | |
| kind = File.basename file, ".yml" |
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
| if a3 | |
| name, params, ret = a1, a1, a2 | |
| else | |
| name, params, ret = nil, a2, a3 | |
| 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
| use Rack::Bug | |
| map '/my_sweet_rack_app' | |
| run MySweetRackApp.new | |
| end | |
| map '/' | |
| DenyAccessAndRecordRetinaApp.new | |
| 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
| class MySweetRackApp | |
| def initialize | |
| Proc.new { |env| [200, {'Content-Type' => 'text/html'}, ['success']] } | |
| 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
| def anon_access_denied | |
| respond_to do |accepts| | |
| accepts.html do | |
| store_location | |
| redirect_to login_path | |
| end | |
| accepts.xml do | |
| headers["Status"] = "Unauthorized" | |
| headers["WWW-Authenticate"] = %(Basic realm="Web Password") | |
| render :text => "Could't authenticate you", :status => '401 Unauthorized' |
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
| def can_checkout_movie? | |
| account_is_current? && | |
| available_rental_slots? && | |
| late_fees_within_limit? | |
| end |