Check out
- https://github.com/thoughtbot/guides/tree/master/style
- https://github.com/styleguide
- https://gist.github.com/bobbygrace/9e961e8982f42eb91b80
The following are key points
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<?qbxml version="7.0"?> | |
<QBXML> | |
<QBXMLMsgsRq onError="continueOnError"> | |
<BillAddRq> | |
<BillAdd> | |
<VendorRef> | |
<ListID>80000438-1429823956</ListID> | |
</VendorRef> | |
<ItemLineAdd> |
// see if the browser supports console.log - fail gracefully if it doesn't | |
try { | |
console.log(); | |
console.debug(); | |
console.assert(); | |
} catch(e) { | |
console = { | |
log: function() {}, | |
debug: function() {}, | |
assert: function() {} |
➜ disko git:(fix-rubypants) ✗ rbenv local 2.1.0 | |
➜ disko git:(fix-rubypants) ✗ rspec | |
....................................................................................................................................................................................... | |
Finished in 9.92 seconds | |
183 examples, 0 failures | |
Randomized with seed 4522 |
# Add the following to your Gemfile | |
# gem 'rubypants-unicode', '~>0.2.3', require: false | |
begin | |
require 'rubypants-unicode' | |
rescue LoadError => _ | |
abort "Missing dependency 'rubypants-unicode' for RubyPantsFilter." | |
end | |
module HTML |
module FourOhFour | |
extend ActiveSupport::Concern | |
included do | |
rescue_from ActiveRecord::RecordNotFound, ActionController::RoutingError, with: :render_404 | |
end | |
def render_404 | |
render template: 'error_pages/404', status: :not_found, format: [:html] and return false | |
end |
$(document).on 'click', '[data-confirm]', (event) -> | |
$target = $(event.target) | |
unless confirm($target.data('confirm')) | |
event.preventDefault() | |
return false |
module Rangy | |
extend ActiveSupport::Concern | |
included do | |
rescue_from ActiveRecord::StatementInvalid, RangeError, ArgumentError do |exception| | |
if exception.message =~ /is out of range for type integer|invalid offset|invalid value for Integer/ | |
render text: 'Not found', status: :not_found | |
end | |
end | |
end |
$(document).ready(function() { | |
var token = $('meta[name="csrf-token"]').attr('content') | |
$.ajaxPrefilter(function(options, originalOptions, xhr){ | |
xhr.setRequestHeader('X-CSRF-Token', token); | |
}) | |
}) |
Check out
The following are key points
module Griddler | |
class Address | |
def initialize(address) | |
@address = address | |
end | |
def some_method_name(type=:hash) | |
if type == :hash | |
parsed_address | |
else |