Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cleanup topic last anchor function.

  • Loading branch information...
commit 54c26b95beee275d59061a4399a7ba3aa1ad9f9c 1 parent fda79ec
Rei chloerei authored
6 app/controllers/application_controller.rb
@@ -39,13 +39,11 @@ def extract_locale_from_accept_language_header
39 39 end
40 40
41 41 def topic_path_with_last_anchor(topic)
42   - anchor = (topic.replies_count == 0 ? nil : "replies-#{topic.replies_count}")
43   - topic_path(topic, :anchor => anchor)
  42 + topic_path(topic, :anchor => topic.last_anchor)
44 43 end
45 44
46 45 def topic_url_with_last_anchor(topic)
47   - anchor = (topic.replies_count == 0 ? nil : "replies-#{topic.replies_count}")
48   - topic_url(topic, :anchor => anchor)
  46 + topic_url(topic, :anchor => topic.last_anchor)
49 47 end
50 48
51 49 def render_404(exception = nil)
4 app/models/topic.rb
@@ -38,6 +38,10 @@ def self.create_topic_hash(topic_ids)
38 38 topic_hash
39 39 end
40 40
  41 + def last_anchor
  42 + replies_count == 0 ? nil : "replies-#{replies_count}"
  43 + end
  44 +
41 45 def last_page
42 46 replies_count == 0 ? 1 : (replies_count / 20.to_f).ceil
43 47 end

0 comments on commit 54c26b9

Please sign in to comment.
Something went wrong with that request. Please try again.