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
Check out
The following are key points
$(document).ready(function() { | |
var token = $('meta[name="csrf-token"]').attr('content') | |
$.ajaxPrefilter(function(options, originalOptions, xhr){ | |
xhr.setRequestHeader('X-CSRF-Token', token); | |
}) | |
}) |
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 |
// 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() {} |
$(document).on 'click', '[data-confirm]', (event) -> | |
$target = $(event.target) | |
unless confirm($target.data('confirm')) | |
event.preventDefault() | |
return false |
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 |
# 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 |
➜ 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 |
#<ActionView::PathSet:0x007fc51b65c240 @paths=[#<ActionView::OptimizedFileSystemResolver:0x007fc513e22810 @pattern=":prefix/:action{.:locale,}{.:formats,}{.:handlers,}", @cache=#<ActionView::Resolver::Cache:0x007fc513e227e8 @data=#<ActionView::Resolver::Cache::SmallCache:0x007fc513e227c0 @backend={}, @default_proc=#<Proc:0x007fc51b545208@/Users/r38y/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.0.3/lib/action_view/template/resolver.rb:48 (lambda)>>>, @path="/Users/r38y/Sites/bntp.bauernet.me/app/views/site_overrides/j-14.com">, #<ActionView::OptimizedFileSystemResolver:0x007fc51b54d4f8 @pattern=":prefix/:action{.:locale,}{.:formats,}{.:handlers,}", @cache=#<ActionView::Resolver::Cache:0x007fc51b54d4d0 @data=#<ActionView::Resolver::Cache::SmallCache:0x007fc51b54d4a8 @backend={}, @default_proc=#<Proc:0x007fc51b545208@/Users/r38y/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.0.3/lib/action_view/template/resolver.rb:48 (lambda)>>>, @path="/Users/r38y/Sites/bntp.bauernet.me/app/views">] |
# this is an initializer and used to set up various themes | |
# so we can use the same instances on each request | |
# I'm wondering if $path_set_registry should be a | |
# constant instead of a global variable | |
$path_set_registry = {} | |
Dir.entries('app/views/site_overrides').reject{|e| e.in?(['.', '..'])}.each do|domain| | |
paths = ["app/views/site_overrides/#{domain}"] | |
$path_set_registry[domain] = ActionView::PathSet.new(paths) | |
end |