Created
August 26, 2011 13:40
-
-
Save urbanautomaton/1173425 to your computer and use it in GitHub Desktop.
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
module LayoutHelper | |
def page_description | |
begin | |
vars = [:@question, :@user, :@topic, :@tribe, :@challenge, :@product] | |
dumps = Hash[*(vars.map{|v| [v, instance_variable_get(v).inspect]}.flatten)] | |
description = case | |
when @question then @question.background | |
when @user && @user.bio.present? then @user.bio | |
when @user && @user.sports.present? then @user.sports_list | |
when @topic then @topic.body | |
when @tribe then @tribe.description | |
when @challenge then @challenge.description | |
when @product then @product.description | |
else "Tribesports: Connect with sports people who share your interests & create your complete sports profile. We want to inspire you to get more active and improve at your sports." | |
end | |
strip_tags(description) | |
rescue NoMethodError => e | |
new_dumps = Hash[*(vars.map{|v| [v, instance_variable_get(v).inspect]}.flatten)] | |
logger.info "[IMPOSSIBLE] BUG DETECTED" | |
logger.info "[IMPOSSIBLE] Before!" | |
dumps.each do |var, dump| | |
logger.info "[IMPOSSIBLE] #{var.to_s} => #{dump}" | |
end | |
logger.info "[IMPOSSIBLE] After!" | |
new_dumps.each do |var, dump| | |
logger.info "[IMPOSSIBLE] #{var.to_s} => #{dump}" | |
end | |
raise | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment