Skip to content

Instantly share code, notes, and snippets.

@mb-dev
mb-dev / simple_form_error_render.js.coffee
Created April 3, 2013 21:54
Simple Form error rendering
form_prefix = 'chapter'
@activeView.$el.find('.help-inline').remove()
@activeView.$el.find('.control-group').removeClass('error')
if(data.errors and data.errors.messages and _(data.errors.messages).keys().length > 0)
_(data.errors.messages).each (value, key, list) =>
@activeView.$el.find('#' + form_prefix + '_' + key).closest('.control-group').addClass('error')
$('<span class="help-inline">' + value + '</span>').insertAfter(@activeView.$el.find('#' + form_prefix + '_' + key))
Product.joins(:brand).where(brand: {id: 1})
Product.joins(:brand).where('brand.id = 1')
Product.joins(:brand).where('brand.id = 1')
@mb-dev
mb-dev / application.js
Created March 3, 2013 23:00
Turbolinks in application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
@mb-dev
mb-dev / Gemfile
Created March 3, 2013 22:04
Rails 4 gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.beta1'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
@mb-dev
mb-dev / filter_parameter_logger.rb
Created March 3, 2013 21:44
Filter parameter logger
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
@mb-dev
mb-dev / session_store.rb
Created March 3, 2013 21:41
Session Store
# Be sure to restart your server when you modify this file.
Sample::Application.config.session_store :encrypted_cookie_store, key: '_sample_session'
@mb-dev
mb-dev / wrap_parameters.rb
Created March 3, 2013 21:39
Root element is disabled by default
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters :format => [:json]
end
@mb-dev
mb-dev / boot.rb
Created March 3, 2013 21:38
Require rubygems removed from boot.rb
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])