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 Validations | |
class Validations::ExpiryMonthValidator < ActiveModel::EachValidator | |
include ActiveMerchant::Billing::CreditCardMethods | |
def validate_each(record, attribute, value) | |
record.errors[attribute] << 'is not a valid month' unless record.valid_month?(value) | |
end | |
end | |
end |
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 Nokogiri::XML | |
class Document | |
def to_hash | |
self.root.element? ? self.root.to_hash : {self.root.name => self.root.text} | |
end | |
end | |
class Element | |
def to_hash |
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
1.9.3p194 :006 > pp Ckeditor.assets | |
["ckeditor/adapters/jquery.js", | |
"ckeditor/ckeditor.js", | |
"ckeditor/ckeditor_basic.js", | |
"ckeditor/ckeditor_basic_source.js", | |
"ckeditor/ckeditor_source.js", | |
"ckeditor/config.js", | |
"ckeditor/lang/_languages.js", | |
"ckeditor/lang/af.js", | |
"ckeditor/lang/ar.js", |
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/workers/base_task.rb | |
class BaseTask | |
def self.perform(*args) | |
ActiveRecord::Base.verify_active_connections! | |
self.perform_delegate(*args) | |
end | |
def self.perform_delegate(*args) # override this | |
return args |
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/views/line_items/decrement.js.erb --> | |
$('#cart').html("<%= escape_javascript(render(@cart)) %>"); | |
$('#current_item').css({'background-color':'#88ff88'}).animate({'background-color':'#114411'}, 1000); | |
if ($('#cart tr').length==1) { | |
// Hide the cart | |
$('#cart').hide('blind', 1000); | |
} |
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
# config/environment/development.rb | |
config.action_mailer.delivery_method = :smtp | |
config.action_mailer.smtp_settings = YAML.load_file(Rails.root.join('config', 'email.yml')[Rails.env]).to_options |
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/views/sessions/new.html.erb --> | |
<div class="depot_form"> | |
<% if flash[:alert] %> | |
<p id="notice"><%= flash[:alert] %></p> | |
<% end %> | |
<%= form_tag do %> | |
<fieldset> | |
<legend>Please Log In</legend> | |
<div> | |
<%= label_tag :name, '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
views/users/_form.html.erb --> | |
<div class="depot_form"> | |
<%= form_for @user do |f| %> | |
# ... | |
<fieldset> | |
<legend>Enter User Details</legend> | |
<div> | |
<%= f.label :name %>: | |
<%= f.text_field :name, size: 40 %> | |
</div> |
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
<VirtualHost *:80> | |
ServerName depot.yourhost.com | |
DocumentRoot /home/ruby/depot/public/ | |
<Directory /home/ruby/depot/public> | |
AllowOverride all | |
RailsEnv development | |
Options -MultiViews | |
Order allow,deny | |
Allow from all | |
</Directory> |
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
# config/deploy.rb | |
require 'bundler/capistrano' | |
# be sure to change these | |
set :user, 'rubys' | |
set :domain, 'depot.pragprog.com' | |
set :application, 'depot' | |
# adjust if you are using RVM, remove if you are not | |
require "rvm/capistrano" | |
set :rvm_ruby_string, '1.9.3' |
OlderNewer