I have a question model much like stackoverflow.
A user can add a question. In the question form there is :Title, :topics, :place, :description
Each topic has its own show page which has a feed of questions that contain the topic.
I want to add a feature so that when a user is on the show page of the topic there is a follow button and the user will be able to follow the topic.
I'm not sure if acts_as_taggable has an in built feature to do so? I am using acts_as_follower so users can follow each other and this is all working fine!
I was going to try to use acts_as_follower on the topics but I have no idea how since there is no 'topic' model as it is created via acts_as_taggable_on
topic_controller.rb for show page
class TopicController < ApplicationController
def index
@questions = Question.tagged_with(params[:topic])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @questions }
end
end
end
Any ideas and code will help alot,
Thanks!
You can create a Topic model that inherits from ActsAsTaggableOn::Tag, and add acts_as_followable to that model.
# app/models/topic.rb
class Topic < ActsAsTaggableOn::Tag
acts_as_followable
end
Then, you can use topic as your tag:
# app/models/post.rb
class Post < ActiveRecord::Base
acts_as_taggable_on :topics
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With