I am using acts-as-taggable-on gem. It creates tags
and taggings
tables automatically. But I wanted to add an additional column called status
to tags
table. I generated a migration to add status
column.
I then created a file named tag.rb
under app/models
class Tag < ApplicationRecord
enum status: { public: 0, private: 1 }
end
Tag.first.private?
works
but
ActsAsTaggableOn::Tag.first.private?
is not working
Throws this error:
NoMethodError (undefined method 'is_private?' for #<ActsAsTaggableOn::Tag:0x00007fb8414b4028>)
I even did
module ActsAsTaggableOn
class Tag < ApplicationRecord
enum status: { public: 0, private: 1 }
end
end
Somehow, this too doesn't work. Can someone point out what's wrong.
Edit: This is the migration file
class AddStatusToTags < ActiveRecord::Migration[5.2]
def change
add_column :tags, :status, :integer, default: 0, null: false
end
end
Use ::ActiveRecord::Base
instead of ApplicationRecord
module ActsAsTaggableOn
class Tag < ::ActiveRecord::Base
enum status: { public: 0, private: 1 }
end
end