This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Package < ActiveRecord::Base | |
has_many :products, :through => :packagings, extend => QuantityAssociation | |
# ... do stuff | |
end | |
module QuantityAssociation | |
def include_duplicates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# db/migrations/20120118012543_create_site_configuration.rb | |
class CreateSiteConfigurations < ActiveRecord::Migration | |
def change | |
create_table :site_configurations do |t| | |
t.string :key | |
t.text :value | |
t.string :form_type | |
t.string :form_collection_command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changeViewportMeta = function() { | |
$('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=1, maximum-scale=1.3, width=device-width'); | |
if ($(window).width() <= 320) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.63, maximum-scale=1.3, width=480'); | |
} else if ($(window).width() <= 480) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.89, maximum-scale=1.3, width=480'); | |
} else if ($(window).width() <= 768) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.8, maximum-scale=1.3, width=920'); | |
} else if ($(window).width() <= 1024) { | |
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.85, maximum-scale=1.3, width=920'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def add_new_git_template | |
# Paths | |
home_dir = File.expand_path('~') | |
template_dir = File.join(home_dir, ".git_template") | |
hooks_dir = File.join(template_dir, "/hooks") | |
pre_commit_file = File.join(hooks_dir, "pre-commit") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveAdminHelper | |
def admin_arbre_context | |
@admin_arbre_context ||= Arbre::Context.new(assigns, self) | |
end | |
def default_renderer | |
case controller.send(:resource_class).name | |
when "ActiveAdmin::Page" | |
"page" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/helpers/application_helper.rb | |
module ApplicationHelper | |
def tupleize number | |
units = { | |
1 => "single", | |
2 => "double", | |
3 => "triple", | |
4 => "quadruple", | |
5 => "quintuple", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
describe ExampleMailer do | |
describe :new_user do | |
let(:user) { FactoryGirl.create :user } | |
it "sends to the correct addresses" do | |
# :mail is similar to the controller specs 'get', 'post' etc methods | |
mail :new_user, user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AssociationCounter | |
def count_sql_for(association_sym) | |
association_table_name = reflect_on_association(association_sym).klass.table_name | |
select("count(#{association_table_name}.id) as #{association_sym}_count").joins(association_sym).to_sql | |
end | |
end | |
ActiveRecord::Base.send(:extend, AssociationCounter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :deploy do | |
namespace :assets do | |
task :remove_digests do | |
run %( cd #{latest_release} && bundle exec rake assets:remove_digests RAILS_ENV=#{rails_env}), :once => true | |
end | |
end | |
end | |
after 'deploy:assets:precompile', 'deploy:assets:remove_digests' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :local_path, Dir.pwd | |
namespace :deploy do | |
namespace :assets do | |
desc 'Run asset procompilation locally' | |
task :precompile_locally, :roles => :web, :except => {:no_release => true} do | |
run_locally("bundle exec rake assets:precompile") | |
end |
OlderNewer