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 d75eb570e16f765b5c6acee8f1fc1c8013eeba4f Mon Sep 17 00:00:00 2001 | |
From: Szymon Nowak <szimek@gmail.com> | |
Date: Mon, 11 Oct 2010 19:37:03 +0200 | |
Subject: [PATCH] Return a valid empty JSON on successful PUT and DELETE requests. | |
--- | |
.../lib/action_controller/metal/responder.rb | 20 ++++++++++++++++++++ | |
actionpack/test/controller/mime_responds_test.rb | 19 +++++++++++++++++++ | |
2 files changed, 39 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
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 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
#!/bin/bash | |
if [ -f .rvmrc ]; then | |
source .rvmrc | |
fi |
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
# Paperclip compliant class for uploading files through URL | |
# Simplified version of http://github.com/chris/paperclip_url_support | |
require "open-uri" | |
module Paperclip | |
class UrlTempfile < Tempfile | |
attr :content_type | |
def initialize(url) |
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 ApplicationController < ActionController::Base | |
prepend_before_filter :blitzkrieg | |
def blitzkrieg | |
redirect_to "/berlin" and return if request.path == root_path | |
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
class CreateLocations < ActiveRecord::Migration | |
def self.up | |
create_table :locations do |t| | |
t.datetime :time | |
t.point :geom, :null => false, :srid => 4326, :with_z => true | |
t.float :speed | |
end | |
end | |
def self.down |
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
# Based on I18n::Backend::ActiveRecord::Missing, but provides some additional features: | |
# - creates Translation object for each locale defined in I18n.available_locales | |
# - looks up the translation using Simple backend and sets it as Translation#value | |
# | |
# Important! Remember to provide i18n.plural.keys in your YAML files. For example: | |
# | |
# # en.yml | |
# en: | |
# i18n: | |
# plural: |
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 I18n | |
module Backend | |
# Expirable cache module that stores unpluralized and uninterpolated translations | |
module ExpirableCache | |
include Cache | |
protected | |
def fetch(*args}, &block) | |
locale, key, options = *args | |
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
require 'httparty' | |
require 'json' | |
class Campfire | |
include HTTParty | |
base_uri 'http://your_domain.campfirenow.com' | |
basic_auth 'your_auth_token', 'whatever' | |
headers "Content-Type" => "application/json" | |
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
-# Don't display new assets on form redisplay | |
- unless (form.object.new_record? && form.object.data.dirty?) | |
%li | |
= form.object.name if form.object.data? | |
= form.file_field :data if form.object.new_record? | |
= form.text_field :title | |
= remove_link(form, t('assets.actions.remove')).html_safe! |