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
Rails::Generator::Commands::Create.class_eval do | |
def template(relative_source, relative_destination, template_options = {}) | |
file(relative_source, relative_destination, template_options) do |file| | |
# Evaluate any assignments in a temporary, throwaway binding. | |
vars = template_options[:assigns] || {} | |
b = template_options[:binding] || binding | |
# this no longer works, eval throws "undefined local variable or method `vars'" | |
# vars.each { |k, v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b } | |
vars.each { |k, v| b.local_variable_set(:"#{k}", v) } |
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
require 'rdoc' | |
converter = RDoc::Markup::ToMarkdown.new | |
rdoc = File.read(ARGV[0] || 'README.rdoc') | |
puts converter.convert(rdoc) | |
# ruby rdoc2md.rb > README.md | |
# ruby rdoc2md.rb ABC.rdoc > abc.md |
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
# Navigating | |
visit '/projects' | |
visit post_comments_path(post) | |
# Clicking links and buttons | |
click_link 'id-of-link' | |
click_link 'Link Text' | |
click_button 'Save' | |
click 'Link Text' # Click either a link or a button | |
click 'Button Value' |
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
# (...) | |
Rails.boot! | |
# The code below allow to use Thin as the webserver | |
if $0 == 'script/server' | |
# commands/server.rb (#45) is not cooperative, so we patch Rack itself | |
require 'rack' | |
module Rack::Handler | |
class << self |
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 bash | |
INSTALL_DIR="${INSTALL_DIR:-/opt/local}" | |
VERSION=$2 | |
YAML_VERSION="0.1.4" | |
APP_NAME="ruby" | |
URL="http://ftp.ruby-lang.org/pub/ruby/ruby-$VERSION.tar.bz2" | |
YAML_URL="http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz" | |
PREFIX="$INSTALL_DIR/$APP_NAME/$VERSION" | |
YAML_PREFIX="$INSTALL_DIR/yaml" |
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
brew remove mysql | |
brew cleanup | |
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist | |
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist | |
sudo rm -rf /usr/local/var/mysql |
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
<%= form_for @application, :html => { :class => 'form-horizontal' } do |f| %> | |
<div class="control-group"> | |
<%= f.label :name, :class => 'control-label' %> | |
<div class="controls"> | |
<%= f.text_field :name, :class => 'text_field' %> | |
</div> | |
</div> | |
<div class="control-group"> | |
<%= f.label :checksum, :class => 'control-label' %> | |
<div class="controls"> |
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 Application < ActiveRecord::Base | |
attr_accessible :checksum, :name, :size, :configuration_attributes | |
has_one :configuration, :dependent => :destroy | |
accepts_nested_attributes_for :configuration, :allow_destroy => :true | |
after_initialize :create_new_configuration | |
private |
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 Person < ActiveRecord::Base | |
include Tire::Model::Search | |
include Tire::Model::Callbacks | |
has_many :addresses | |
accepts_nested_attributes_for :addresses, :allow_destroy => true | |
def to_indexed_json | |
{ | |
:addresses => adresses.map{|p| p.name}.compact.reject(&:blank?).uniq, |
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
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
require 'machinist/active_record' | |
require 'machinist/caching/active_record' | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
spec_support = Rails.root.join("spec/support/**/*.rb") |