I have a question model in my rails app. A user can add questions. When adding a question a user can assign it topics and a place.
I followed the railscast on how to set up acts_as_taggable_on for tags, in my case topics.
However, I now want to add the place feature. I had a go myself and had a google around but couldn't find much on having 2 acts_as_taggable items.
If someone could advise me on how to setup a second acts_as_taggable feature on the same acts_as_taggable that would be great
My code so far:
Question.rb
acts_as_taggable
acts_as_taggable_on :topics, :places
questions_controller.rb
def topics
if params[:topic].present?
@questions = Question.tagged_with(params[:topic])
else
@questions = Question.postall
end
end
questions/show.html.erb
<p>Topics: <%= raw @question.tag_list.map { |t| link_to t, topic_path(t) }.join(', ') %></p>
form.html.erb
<%= f.input :tag_list, placeholder: "Topics" %>