This file contains hidden or 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
# ... | |
if defined?(PhusionPassenger) | |
PhusionPassenger.on_event(:starting_worker_process) do |forked| | |
if forked | |
Rails.cache.instance_variable_get(:@data).reset if Rails.cache.class == ActiveSupport::Cache::MemCacheStore | |
ActionController::Base.session_options[:cache].reset | |
end | |
end | |
end |
This file contains hidden or 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
# as we’re going to use Unicorn as the application server | |
# we’re not going to use common sockets | |
# but Unix sockets for faster communication | |
upstream shop { | |
# fail_timeout=0 means we always retry an upstream even if it failed | |
# to return a good HTTP response (in case the Unicorn master nukes a | |
# single worker for timing out). | |
# for UNIX domain socket setups: | |
server unix:/tmp/shop.socket fail_timeout=0; |
This file contains hidden or 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 | |
# encoding: UTF-8 | |
ARGV.reject! { |path| !File.file?(path) } | |
(puts DATA.read.gsub("$0", File.basename($0)); exit 1) if ARGV.empty? | |
ARGV.each do |path| | |
ls = IO.readlines(path) | |
ix = ls[0] !~ /^#!/ ? 0 : 1 | |
next if ls[ix] =~ /#.*?coding\s*[:=]\s*\S/ |
This file contains hidden or 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
c = "\n !\"#'()*+,./01234678;<=ABCDEGINOPRSTUVY[\\]_abcdefghijlmnopqrstuvxy{|}".split('') | |
i = <<'EOT' .gsub(/\n/, '').to_i(36) | |
cuwnbkpknpgvndxhiywcb8v7r6px9dgwojmf4inpx5a0irzlmxiaisomq7ir6zx1yhrkk42gltj7vy | |
nibeul3djwhv9hy0jcjptfh9vvwmnw3xyn4k32gjflrdbb3f1t1xt3w690js9ri5idnch6f9y1ym6r | |
a2e9okgnsrofg1ztnq9zdbtfh7qmhy22psuo3cdxv1aaq3bf7q0bv12nj8ld7tshysxekfz8jwmff7 | |
k0okucxt2abkmapldjqb6m2vzo43r3g4j9zscr8svoi3ktv63jddl5dokfgl1rmi9sygylc8jor243 | |
ywnovju7t8kvuf2bpy33zkp6w7k97lok9ymo8shfs9m83rq85snkiex96hjykqkf8noaeap18b2rvo | |
4vrmdy6a7pm28m5b7ye9e58i0xp89ckgx9xuth43ngwfgmoomp2v5dau2ep3hovpthhmklo47j7ds4 | |
714qvy44hmzk24v95gycadjnqkvrbqqip3k7ap901q0eiuvouweg9mlsm4r6y78rpamf8rlqzltyw8 | |
3uf9qqs9sz0au0hyjicqiu3m5xb40yydj6qfigauo1wlmdctonk3a3e9s5vyhrxqmmck89fsupxprp |
This file contains hidden or 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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
end |
This file contains hidden or 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
if ENV['LOAD_RAILS'] == '1' | |
task :stats => "ma:add_no_rails_dirs_to_stats" | |
namespace :ma do | |
desc "Report code statistics (KLOCs, etc) from the application" | |
task :add_no_rails_dirs_to_stats do | |
require 'rails/code_statistics' | |
::STATS_DIRECTORIES << %w(NoRails\ Lib\ specs spec_no_rails/lib) if File.exist?('spec_no_rails/lib') | |
::CodeStatistics::TEST_TYPES << "NoRails Lib specs" if File.exist?('spec_no_rails/lib') | |
::STATS_DIRECTORIES << %w(NoRails\ Model\ specs spec_no_rails/model) if File.exist?('spec_no_rails/model') |
Rails 3.2 ships with a simple FileWatcher that only reloads your app if any of the files changed.
Besides, it also provides a mechanism to hook up your own file watcher mechanism, so we can use tools like FSSM that hooks into Mac OS X fsevents. This is an example on how to hook your own mechanism (you need Rails master, soon to be Rails 3.2):
-
Copy the
2_file_watcher.rb
file below tolib/file_watcher.rb
-
Add the following inside your Application in
config/application.rb
if Rails.env.development?
This file contains hidden or 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
$('#products').append('<%= j render(@products) %>'); | |
<% if @products.next_page %> | |
$('.pagination').replaceWith('<%= j will_paginate(@products) %>'); | |
<% else %> | |
$('.pagination').remove(); | |
<% end %> |
This file contains hidden or 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 BootstrapFormBuilder < ActionView::Helpers::FormBuilder | |
delegate :capture, :content_tag, :tag, to: :@template | |
%w[text_field text_area password_field collection_select].each do |method_name| | |
define_method(method_name) do |name, *args| | |
errors = object.errors[name].any?? " error" : "" | |
error_msg = object.errors[name].any?? content_tag(:span, object.errors[name].join(","), class: "help-inline") : "" | |
content_tag :div, class: "clearfix#{errors}" do |
OlderNewer