Actions_as_taggable_on and flag tags

I am using RoR 3.0.8 and gem actions_as_taggable_on. I want to make the message have any of the following tags (politics, sport, social, scientific). I want them to select tags when composing a message and do this using checkboxes. Is there a way to get him to say that if the policy checkbox is checked, then @ post.tag_list = 'policy' ?

+8
checkbox ruby-on-rails tags acts-as-taggable-on
source share
2 answers

A bit delayed, but it should work.

<%= form_for(@post) do |f| %> <%= f.label :tag_list %> <%= f.check_box :tag_list, { :multiple => true }, 'politics', nil %> <%= f.check_box :tag_list, { :multiple => true }, 'science', nil %> <%= f.check_box :tag_list, { :multiple => true }, 'social', nil %> <%= f.check_box :tag_list, { :multiple => true }, 'sports', nil %> <% end %> 
+12
source share

Late, but: Checked and tried to apply this answer myself, with rails 5, and the above code worked only when I put: tag_list => [] in post_params. For some reason, just adding: tag_list does not work.

+1
source share

All Articles