Commit e101280c
Changed files (3)
app
app/helpers/my/dashboard_helper.rb
@@ -0,0 +1,11 @@
+module My
+ module DashboardHelper
+ def unique_tags
+ Tag.unique_tags
+ end
+
+ def unique_tools
+ Tag.unique_tools
+ end
+ end
+end
app/models/tag.rb
@@ -0,0 +1,19 @@
+class Tag
+ def self.unique_tools
+ ActsAsTaggableOn::Tag
+ .joins(:taggings)
+ .where(taggings: { context: 'tools' })
+ .order(:name)
+ .pluck(:name)
+ .uniq
+ end
+
+ def self.unique_tags
+ ActsAsTaggableOn::Tag
+ .joins(:taggings)
+ .where(taggings: { context: 'tags' })
+ .order(:name)
+ .pluck(:name)
+ .uniq
+ end
+end
app/views/my/dashboard/index.html.erb
@@ -1,7 +1,8 @@
<% provide(:title, "Dashboard") -%>
<%= content_for :javascript do -%>
<%= javascript_tag do %>
- var ALL_TAGS = [ <% ActsAsTaggableOn::Tag.pluck(:name).sort!.each { |item| %> '<%= item %>', <% } %> ];
+ var ALL_TAGS = <%= raw unique_tags %>;
+ var ALL_TOOLS = <%= raw unique_tools %>;
var disqus_shortname = '<%= ENV['DISQUS_SHORTNAME'] %>';
var disqus_identifier = 'u-<%= current_user.id %>';
var disqus_config = function(){