Skip to content

Instantly share code, notes, and snippets.

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'])
@mb-dev
mb-dev / application.rb
Created March 3, 2013 21:36
Bundler command change on application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Assets should be precompiled for production (so we don't need the gems loaded then)
Bundler.require(*Rails.groups(assets: %w(development test)))
module Sample
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.