_tags.html.erb
#version 1 (just lists out habits tags) <% tag_cloud habit.tag_counts, %w{s m l} |tag, css_class| %> <%= link_to tag.name, tag_path(tag.name), class: css_class %> <% end %> #version 2 <% tag_cloud(@tags, %w(css1 css2 css3 css4)) |tag, css_class| %> <%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %> <% end %>
how can list's out current_user's habits , goals, valuations, quantifieds? f.text_field :tag_list
in _form of each of these 4 models, separate tables in database.
i added below code each of 4 models. here's how looks valuations:
helper
module valuationshelper include actsastaggableon::tagshelper end
controller
class valuationcontroller < applicationcontroller def tag_cloud @tags = valuation.tag_counts_on(:tags) end end
and user model
user.tag_counts_on(:tags) acts_as_tagger acts_as_taggable
i'm using acts-as-taggable-on gem, implemented railscasts. please let me know if need further code or explanation =]
create model called tagalicious
.
since want in sidebar put in application_controller:
before_action :tag_cloud def tag_cloud @tags = tagalicious.tag_counts_on(:tags) end
then in helper:
module tagalicioushelper include actsastaggableon::tagshelper end
then in model:
class tagalicious < activerecord::base belongs_to :habit belongs_to :goal belongs_to :quantified belongs_to :valuation acts_as_taggable end
tag_cloud:
<% tag_cloud(@tags, %w(css1 css2 css3 css4)) |tag, css_class| %> <%= link_to tag.name, tag_path(tag), :class => css_class %> <% end %>
hopefully clarify things. can't figure out how make line in various models <%= f.text_field :tag_list %>
point tagalicious
model.
this can go on in chat if want or maybe try question specific problem.