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
RSpec::Matchers.define :have_errors_on do |attribute, *values| | |
@attribute = attribute | |
@values = values | |
@failed = [] | |
match_for_should do |record| | |
@record = record | |
matches_against?(true) | |
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
RSpec::Matchers.define :allow_assignment_for do |attribute| | |
@attribute = attribute | |
match_for_should do |record| | |
@record = record | |
matches_against?(true) | |
end | |
match_for_should_not do |record| | |
@record = record |
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
RSpec::Matchers.define :accept_nested_attributes_for do |association| | |
@association = association | |
match_for_should do |record| | |
@record = record | |
matches_against?(true) | |
end | |
match_for_should_not do |record| | |
@record = record |
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
RSpec::Matchers.define :have_association do |association| | |
@association = association | |
match_for_should do |record| | |
@record = record | |
matches_against?(true) | |
end | |
match_for_should_not do |record| | |
@record = record |
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
$base-width: 940px; | |
$tablet-width: 768px; | |
$mobile-portrait-width: 300px; | |
$mobile-landscape-width: 420px; | |
$num-columns: 16; | |
$margin: 25px; | |
@mixin clearfix { |
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
@import "compass/css3"; | |
.ribbon { | |
position: absolute; | |
top: 42px; | |
width: 200px; | |
padding: 1px 0; | |
background: #000; | |
color: #eee; | |
@include box-shadow(rgba(#000, 0.5) 0 0 10px); |
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
def load_files_from(files=[]) | |
postponed_files = [] | |
files.each do |f| | |
begin | |
require f | |
rescue | |
postponed_files << f | |
end | |
end | |
load_files_from(postponed_files) unless postponed_files.empty? |
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 ActiveRecord::Base | |
def accessible_attributes | |
accessible_attributes = self.class.accessible_attributes.select do |attr| | |
!attr.blank? | |
end | |
attributes.slice(*accessible_attributes) | |
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
require 'net/http' | |
module HTTPVerbs | |
def get(url) | |
uri = URI.parse url | |
http_request = Net::HTTP::Get.new(uri.request_uri) | |
Net::HTTP.new(uri.host, uri.port).request(http_request) | |
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
$('.cep').blur(function() { | |
var cep = $(this).attr('value').replace(/-/, ''); | |
$.ajax({ | |
url : 'http://cep.correiocontrol.com.br/' + cep + '.json', | |
dataType: 'json', | |
success: function(data) { | |
console.log(data); | |
$('#address').attr('value', data.logradouro); | |
$('#neighborhood').attr('value', data.bairro); | |
$('#city').attr('value', data.localidade); |
OlderNewer