View gist:3436
def translate(locale, key, options = {}) | |
# ... | |
entry = lookup(locale, key, scope) || resolve(locale, key, default, options) || raise(I18n::MissingTranslationData.new(locale, key, options)) | |
# ... | |
end | |
def localize(locale, object, format = :default) | |
raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime) | |
if Symbol == format |
View gist:4838
class Locale # is this a String? maybe not. | |
attr :language, :script, :region, :variant, :extension, :private_use | |
def valid? | |
# validate against RFC4646 | |
end | |
def parent | |
# return 'en' for 'en-US' etc. | |
end | |
end |
View gist:7818
activerecord.errors.models.content.attributes.topic.invalid | |
activerecord.errors.models.content.invalid | |
activerecord.errors.messages.invalid | |
# with STI | |
activerecord.errors.models.post.attributes.topic.invalid # Topic is invalid for post | |
activerecord.errors.models.post.invalid # Post is invalid | |
activerecord.errors.models.content.attributes.topic.invalid # Topic is invalid for content | |
activerecord.errors.models.content.invalid # Content is invalid | |
activerecord.errors.messages.invalid # This is invalid |
View gist:9186
Who's up to a post-railsconfeu08-coolest-quotes-tshirt-site? | |
Rails doesn't scale! (Oscar Wilde) | |
Look at all the things I'm not doing! (DHH) | |
Most people don't need Zulu on your website. (Josh Harvey) | |
t :rails (Sven Fuchs) | |
That is sooo "Linux"! (Jeremy Kemper) | |
Java is to Javascript what car is to carpet (at BoF "Xing on Rails") | |
No suitable for a t-shirt but still noteworthy: |
View output.txt
# see http://pastie.org/274816 and http://pastie.org/274829 | |
# I have: "foo" | |
# I need: ['f', 'fo', 'foo'] | |
require 'benchmark' | |
def using_split(str) | |
str.split(//mu).inject([]) do |arr, char| | |
arr << arr[-1].to_s + char.to_s | |
end |
View gist:14807
// line 272 and following - seems to work for me, at least i can drag across multiple tbodys | |
if (movingDown && jQuery.tableDnD.dragObject != currentRow) { | |
currentRow.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling); | |
} else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) { | |
currentRow.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow); | |
} |
View i wish i could write ...rb
describe "POST to :create" do | |
action { post :create, @params } | |
all_with :an_empty_blog | |
it_assigns :article | |
with :login_as_admin do | |
it "succeeds", with => :valid_article_params do | |
it_saves :article | |
it_assigns :flash :notice => :not_nil |
View gist:39312
when you read: | |
with [:foo, :bar], :baz | |
does that mean: | |
with(:foo AND :baz) OR with(:bar AND :baz) | |
or does it mean: | |
with(:foo AND :bar) OR with(:baz) | |
i.e. would the nested args array indicate a logical OR or a logical AND? |
View gist:53598
# from http://weblog.jamisbuck.org/2006/3/9/integration-testing-in-rails-1-1 | |
require "#{File.dirname(__FILE__)}/../test_helper" | |
class StoriesTest < ActionController::IntegrationTest | |
fixtures :accounts, :ledgers, :registers, :people | |
def test_signup_new_person | |
new_session do |bob| | |
bob.goes_to_login |
View url_history.rb
ActionController::Routing::Routes.draw do |map| | |
map.from_plugins | |
map.filter 'force_html' | |
end |
OlderNewer