Module: PopularityContest::ViewHelpers
- Defined in:
- lib/popularity_contest/view_helpers.rb
Instance Method Summary collapse
- #all_popular_content(content_type) ⇒ Object
- #popular_content(content_type, limit = 10, date = Date.today.strftime("%y-%m-%d")) ⇒ Object
- #popular_count_hit_jquery(content_type, content_id) ⇒ Object
- #popular_count_hit_path(content_type, content_id) ⇒ Object
Instance Method Details
#all_popular_content(content_type) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/popularity_contest/view_helpers.rb', line 40 def all_popular_content(content_type) begin PopularityContest::all_popular(content_type, redis_connection) rescue [] end end |
#popular_content(content_type, limit = 10, date = Date.today.strftime("%y-%m-%d")) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/popularity_contest/view_helpers.rb', line 32 def popular_content(content_type, limit=10, date=Date.today.strftime("%y-%m-%d")) begin PopularityContest::most_popular(content_type, redis_connection, limit) rescue [] end end |
#popular_count_hit_jquery(content_type, content_id) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/popularity_contest/view_helpers.rb', line 11 def popular_count_hit_jquery(content_type, content_id) begin url = build_path(content_type, content_id) <<-SJS <script> if (jQuery) { (function(window, document, $, undefined) { $.ajax({ url: '#{url}', dataType: 'html', cache: false }) }(window, document, jQuery)); } </script> SJS rescue "<!-- error occurred in PopularityContest :| -->" end end |
#popular_count_hit_path(content_type, content_id) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/popularity_contest/view_helpers.rb', line 3 def popular_count_hit_path(content_type, content_id) begin build_path(content_type, content_id) rescue "<!-- error occurred in PopularityContest :| -->" end end |