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
From 77883e5358e488d10daa34e8490a6c57b5e0a536 Mon Sep 17 00:00:00 2001 | |
From: Nicolas Blanco <slainer68@gmail.com> | |
Date: Sat, 7 Aug 2010 22:05:04 +0200 | |
Subject: [PATCH 3/3] Adds basic Capistrano task for Bundler. | |
To use it, just require 'bundler/capistrano' in your Capistrano deploy file (deploy.rb). | |
Bundler will be activated after each new deployment. | |
--- | |
lib/bundler/capistrano.rb | 23 +++++++++++++++++++++++ | |
1 files changed, 23 insertions(+), 0 deletions(-) |
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
[$]nicolas@nicolas-desktop:[git:master] /home/nicolas/projects/novagolf-> gem env | |
RubyGems Environment: | |
- RUBYGEMS VERSION: 1.3.7 | |
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i686-linux] | |
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8 | |
- RUBY EXECUTABLE: /usr/local/bin/ruby | |
- EXECUTABLE DIRECTORY: /usr/local/bin | |
- RUBYGEMS PLATFORMS: | |
- ruby | |
- x86-linux |
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
[$]nicolas@nicolas-desktop:[git:models_refactoring] /home/nicolas/projects/novagolf-> cat Gemfile | |
source 'http://rubygems.org' | |
gem 'rails', '3.0.0.rc' | |
gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :branch => 'rails3' | |
gem 'state_machine', :git => 'git://github.com/pluginaweek/state_machine.git' | |
gem 'simple_autocomplete' |
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 FormBuilderHelpers | |
class Html5 | |
def self.options_from(object, attribute) | |
return {} unless object.class.respond_to?(:validators_on) | |
{}.tap do |options| | |
options[:required] = true if object.class.validators_on(attribute).any? { |validator| validator.is_a?(ActiveModel::Validations::PresenceValidator) } | |
if validator = object.class.validators_on(attribute).select { |validator| validator.is_a?(ActiveModel::Validations::InclusionValidator) && validator.options[:in].is_a?(Range) }.last | |
options[:min] = validator.options[:in].min |
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
[$]nicolas@nicolas-desktop:[git:master] /home/nicolas/projects/novagolf-> rspec spec | |
/home/nicolas/projects/novagolf/config/application.rb:10 | |
Bundler.require(:default, Rails.env) if defined?(Bundler) | |
(rdb:1) eval Devise | |
NameError Exception: uninitialized constant Devise | |
(rdb:1) eval Warden | |
NameError Exception: uninitialized constant Warden | |
(rdb:1) next | |
/home/nicolas/projects/novagolf/config/application.rb:12 | |
module Novagolf |
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
ree-1.8.7-2010.02 > [1,2,3,4].take_while { |i| i < 3 } | |
[ | |
[0] 1, | |
[1] 2 | |
] | |
ree-1.8.7-2010.02 > [1,2,3,4].drop_while { |i| i < 3 } | |
[ | |
[0] 3, | |
[1] 4 | |
] |
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
ree-1.8.7-2010.02 > a = [1, 2, 3, 4] | |
[ | |
[0] 1, | |
[1] 2, | |
[2] 3, | |
[3] 4 | |
] | |
ree-1.8.7-2010.02 > a.inject({}) { |m, o| m["val_#{o}"] = o; m; } | |
{ |
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
ree-1.8.7-2010.02 > (3.days.ago.to_date..3.days.from_now.to_date).to_a | |
[ | |
[0] Tue, 21 Sep 2010, | |
[1] Wed, 22 Sep 2010, | |
[2] Thu, 23 Sep 2010, | |
[3] Fri, 24 Sep 2010, | |
[4] Sat, 25 Sep 2010, | |
[5] Sun, 26 Sep 2010, | |
[6] Mon, 27 Sep 2010 | |
] |
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 SearchObject | |
extend ActiveModel::Naming | |
include ActiveModel::Validations | |
include ActiveModel::MassAssignmentSecurity | |
def to_key; nil; end | |
def initialize(attributes = {}) | |
if attributes.present? | |
sanitize_for_mass_assignment(attributes).each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") } |
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 WebAppTheme | |
class FormBuilder < ActionView::Helpers::FormBuilder | |
def self.create_tagged_field(method_name) | |
define_method(method_name) do |label, *args| | |
options = args.last.is_a?(Hash) ? args.pop : {} | |
object_class_name = object.class.to_s.underscore | |
label_title = (options.delete(:title) || I18n.t("activerecord.attributes.#{object_class_name}.#{label}", :default => label.to_s.humanize)) | |
label_description = options.delete(:description) || I18n.t("activerecord.attributes.#{object_class_name}.descriptions.#{label}", :default => "") |