Rescue nil values for attribute_values in User

This commit is contained in:
chris2tof 2011-11-16 09:47:09 +08:00
parent bcf487f264
commit c4810274ec
1 changed files with 8 additions and 4 deletions

View File

@ -1,12 +1,16 @@
module Panel::UserHelper module Panel::UserHelper
def show_user_attribute(object, key, locale = '') 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) } 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? if locale.to_s.blank?
attribute['key'] attribute['key']
else else
attribute[locale.to_s] attribute[locale.to_s]
end end
else
''
end
end end
end end