View default_params.rb
require 'active_support/concern'
module DefaultParams
extend ActiveSupport::Concern
included do
let(:default_params) { {locale: I18n.locale} }
def process_with_default_params(action, http_method = 'GET', *args)
View routing.rb
# SO:
module Routing
extend ActiveSupport::Concern
include Rails.application.routes.url_helpers
included do
def default_url_options
{ :locale => I18n.locale }
View check_for_memcached.rb
# Use a different cache store based on memcached is running or not
# check if memcached is running; if it is, use that instead of the default memory cache
Timeout.timeout(0.5) {"localhost", 11211) { } }
config.cache_store = :dalli_store, %w(localhost:11211), {namespace: Rails.application.class.parent_name, expires_in:, compress: true}
$stderr.puts "Using memcached on localhost:11211"
rescue StandardError
$stderr.puts "memcached not running, caching to memory"
Toggle Display
Put the data attributes on a button or link
Required attributes:
data-toggle: 'display'
data-target: selector of target element
Optional attibutes:
data-effect: 'slide', 'fade', other values (no effect)
View hoverable.scss
// This class use direct selector '>' since you might want to use it nested way
// Like hover menu, then hover button
.hoverable-container {
& > .hoverable-content.on-hover {
display: none;
&:hover {
// Hide the default one
jQuery ($) ->
$(document).on "click", '.js-toggleable-container', ->
View placeholder.js
* This hack creates the placeholder effect on old browsers
* Source:
* Dependency: jQuery & Modernizr
* It also add a class to the input so you can style it to look like normal placeholder
jQuery(function($) {