Created
August 16, 2012 13:51
-
-
Save mrship/3370258 to your computer and use it in GitHub Desktop.
Simple form hack
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
if Rails.env.staging? | |
module SimpleForm | |
module Inputs | |
class Base | |
def translate(namespace, default='') | |
model_names = lookup_model_names.dup | |
lookups = [] | |
while !model_names.empty? | |
joined_model_names = model_names.join(".") | |
model_names.shift | |
# lookups << :"#{joined_model_names}.#{lookup_action}.#{reflection_or_attribute_name}" | |
lookups << :"#{joined_model_names}.#{reflection_or_attribute_name}" | |
end | |
lookups << :"defaults.#{lookup_action}.#{reflection_or_attribute_name}" | |
lookups << :"defaults.#{attribute_name}" | |
lookups << default | |
I18n.t(lookups.shift, :scope => :"simple_form.#{namespace}", :default => lookups).presence | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment