Skip to content

Commit

Permalink
Improve error message for missing translation_key.
Browse files Browse the repository at this point in the history
  • Loading branch information
kytrinyx committed Dec 26, 2011
1 parent 40d640c commit da25441
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/faker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def flexible(key)
# girls_name: ["Alice", "Cheryl", "Tatiana"]
# Then you can call Faker::Name.girls_name and it will act like #first_name
def method_missing(m, *args, &block)
super unless @flexible_key

# Use the alternate form of translate to get a nil rather than a "missing translation" string
if translation = translate(:faker)[@flexible_key][m]
translation.respond_to?(:sample) ? translation.sample : translation
Expand Down

0 comments on commit da25441

Please sign in to comment.