Rescue nil values for attribute_values in User

This commit is contained in:
chris2tof committed 2011-11-16 18:41:09 +08:00
1 parent bcf487f264
commit c4810274ec
1 file changed
+8 -4
+8 -4
View File
@@ -1,11 +1,15 @@
module Panel::UserHelper
def show_user_attribute(object, key, locale = '')
attribute = object.attribute_values.detect {|av| av.key.to_s.eql?(key.to_s) || av[locale.to_s].eql?(locale.to_s) }
if locale.to_s.blank?
attribute['key']
attribute = object.attribute_values.detect {|av| av.key.to_s.eql?(key.to_s) || av[locale.to_s].eql?(locale.to_s) } rescue nil
if attribute
if locale.to_s.blank?
attribute['key']
else
attribute[locale.to_s]
end
else
attribute[locale.to_s]
''
end
end