Skip to content

Commit

Permalink
adding nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
sbower committed Oct 18, 2011
1 parent acf4ca1 commit 84292e9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/public_activity/activity.rb
Expand Up @@ -40,7 +40,7 @@ class Activity < ActiveRecord::Base
# @article.activities.last.text #=> "Someone has created an article 'Rails 3.0.5 released!'"
def text(params = {})
erb_template = resolveTemplate(key)
if !self.template.nil? && !erb_template.nil?
if !erb_template.nil?
parameters.merge! params
renderer = ERB.new(erb_template)
renderer.result(binding)
Expand All @@ -52,15 +52,16 @@ def text(params = {})
private
def resolveTemplate(key)
res = nil
key.split(".").each do |k|
if res.nil?
res = self.template[k]
else
res = res[k]
if !self.template.nil?
key.split(".").each do |k|
if res.nil?
res = self.template[k]
else
res = res[k]
end
end
end
end
res
end

end
end

0 comments on commit 84292e9

Please sign in to comment.