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
# | |
# This is a default deploy.rb | |
# it is included into the Rails 3 Basic Template by default. | |
# | |
require 'active_support' | |
require 'lib/deploy_helpers' | |
DEPLOY_CONFIG = YAML::load(File.open("#{Rails.root}/config/deploy.yml")) |
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 | |
# To avoid having to add a password for sudo, visudo and add | |
# deployusername ALL=(ALL) NOPASSWD: /etc/init.d/unicorn reload | |
task :start do | |
sudo "/etc/init.d/unicorn start" | |
end | |
task :stop do | |
sudo "/etc/init.d/unicorn stop" |
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
# 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 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 MultiParameterAttributes | |
module InstanceMethods | |
def attributes=(attrs) | |
multi_parameter_attributes = [] | |
attrs.each do |name, value| | |
return if attrs.blank? | |
if name.to_s.include?("(") | |
multi_parameter_attributes << [ name, value ] | |
else | |
writer_method = "#{name}=" |
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
@import "blueprint/reset"; | |
// Here is where you can define your constants for your application and to configure the blueprint framework. | |
// Feel free to delete these if you want keep the defaults: | |
$blueprint-grid-columns: 24; | |
$blueprint-container-size: 950px; | |
$blueprint-grid-margin: 10px; | |
// Use this to calculate the width based on the total width. | |
// Or you can set $blueprint-grid-width to a fixed value and unset $blueprint-container-size -- it will be calculated for you. |
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 CustomFormBuilder < ActionView::Helpers::FormBuilder | |
def label(method, text = nil, options = {}) | |
options, text = text, nil if text.is_a?(Hash) | |
text ||= method.to_s.humanize | |
text = text.titleize if text.split(' ').size <= 3 | |
if options.key?(:required) |
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
(function($) { | |
var factory = { | |
init:function(opts){ | |
var options = { load:true }; | |
if(opts) $.extend(options, opts); | |
this.each(function(){ |
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
<% | |
# This works for sorting fields using jquery.sortable and fields_for / accepts_nested_attributes_for | |
# Tested with mongoid, haven't tried activerecord. | |
# object is the main object used in form_for (this is a partial in my case) | |
# content_fields is an embeds_many inside of that parent object. | |
# each content_field has a field "position" I'm using to position each item. | |
%> | |
<% object.content_fields.sort{ |x,y| x.position.to_i <=> y.position.to_i }.each_with_index do |cf, ind| %> |
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
# Miscellaneous helper methods to include into applications | |
# include into application_helper.rb | |
module HelperMethods | |
# Creates a navigation link (by default a list item) that has the class 'on' if we are on that particular page or a | |
# page beneath it. | |
# Example: nav_link_to('Blog', 'blog') will have the class of 'on' should we be on /blog or /blog/some_path | |
def nav_link_to(txt, path, attrs = {}, wrapper = :li, &block) |
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
# | |
# This is a default deploy.rb | |
# it is included into the Rails 3 Basic Template by default. | |
# | |
require 'active_support' | |
DEPLOY_CONFIG = YAML::load(File.open("config/deploy.yml")) | |
default_run_options[:pty] = true |
NewerOlder