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
| # Bulk API design | |
| # | |
| # resources :posts | |
| class PostsController < ActiveController::Base | |
| # GET /posts/1,4,50,90 | |
| # post_url([ @post, @post ]) | |
| def show_many | |
| @posts = Post.find(params[:ids]) | |
| 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
| # Patch to support customized request headers in your Capybara tests | |
| # when you're using the RackTest driver, based on an Aslak Hellesøy's gist: | |
| # https://gist.github.com/358664 | |
| # | |
| # Please note that some drivers don't allow access to headers, see: | |
| # https://github.com/jnicklas/capybara/issuesearch?state=closed&q=header#issue/17 | |
| class Capybara::Driver::RackTest < Capybara::Driver::Base | |
| def env |
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
| module SimpleForm | |
| class FormBuilder < ActionView::Helpers::FormBuilder | |
| # You can just override the default submit button and add the functionality. | |
| # | |
| # Simple usage: | |
| # f.button :submit 'Send!', :cancel_link => root_path | |
| # | |
| def submit(*args) | |
| cancel_link = args.last.is_a?(Hash) && args.last.delete(:cancel_link) | |
| submit_button = super |
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 "xpath" # XPath is a separate gem now | |
| module Cucumber | |
| module Rails | |
| module CapybaraSelectDatesAndTimes | |
| def select_date(field, options = {}) | |
| date = Date.parse(options[:with]) | |
| selector = %Q{.//fieldset[contains(./legend, "#{field}")]} | |
| within(:xpath, selector) do | |
| find(:xpath, '//select[contains(@id, "_1i")]').find(:xpath, ::XPath::HTML.option(date.year.to_s)).select_option |
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
| # ==================== | |
| # Spell: Dynamic Proxy | |
| # ==================== | |
| # Forward to another object any messages that don’t match a method. | |
| class MyDynamicProxy | |
| def initialize(target) | |
| @target = target | |
| 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
| # unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D | |
| rails_env = ENV['RAILS_ENV'] || 'production' | |
| # 16 workers and 1 master | |
| worker_processes (rails_env == 'production' ? 16 : 4) | |
| # Load rails+github.git into the master before forking workers | |
| # for super-fast worker spawn times | |
| preload_app true |
NewerOlder