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
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 |
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 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 |
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
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 |
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
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: |
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
# 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 |
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
// 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); | |
} | |
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
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 |
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
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? |
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 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 |
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
ActionController::Routing::Routes.draw do |map| | |
map.from_plugins | |
map.filter 'force_html' | |
end |
OlderNewer