Skip to content
This repository has been archived by the owner on May 5, 2019. It is now read-only.

Commit

Permalink
fix when no tag
Browse files Browse the repository at this point in the history
  • Loading branch information
archiloque committed Jan 25, 2016
1 parent 8dcb526 commit b40a9c4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tumblr_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ def json(code, message)

@posts.each do |post|
post.loaded_tumblr = tumblrs_by_id[post.tumblr_id]
post.loaded_tags = post.tags.
sort.
collect { |tag| {:name => tag, :value => (tags_with_score[tag] || 0)} }
if post.tags
post.loaded_tags = post.tags.
sort.
collect { |tag| {:name => tag, :value => (tags_with_score[tag] || 0)} }
else
post.loaded_tags = []
end
end

headers 'Cache-Control' => 'no-cache, must-revalidate'
Expand Down Expand Up @@ -419,7 +423,7 @@ def create_post(values, tags_with_score)
end

post_db.tags = values[:tags]
post_db.score = values[:tags].collect{|tag| tags_with_score[tag] || 0}.inject(0, :+)
post_db.score = values[:tags].collect { |tag| tags_with_score[tag] || 0 }.inject(0, :+)
post_db.save
post_db
else
Expand Down

0 comments on commit b40a9c4

Please sign in to comment.