Module: PopularityContest::ViewHelpers

Defined in:
lib/popularity_contest/view_helpers.rb

Instance Method Summary collapse

Instance Method Details



38
39
40
41
42
43
44
# File 'lib/popularity_contest/view_helpers.rb', line 38

def all_popular_content(content_type)
  begin
    PopularityContest::all_popular(content_type, redis_connection)
  rescue
    []
  end
end


30
31
32
33
34
35
36
# File 'lib/popularity_contest/view_helpers.rb', line 30

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


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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)
    "<script>\n(function(window, document, $, undefined) {\n  $.ajax({\nurl: '\#{url}',\ndataType: 'html',\ncache: false\n  })\n}(window, document, jQuery));\n</script>\n    SJS\n  rescue\n    \"<!-- error occurred in PopularityContest :| -->\"\n  end\nend\n"


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