I’m new to rails, and to modeling associations in rails. I have a “Student” model and am planning to add a “Tags” model with associations between the two. Tags need to be dynamically entered by an admin (I’m using the ActiveAdmin gem) and assigned to a student if desired, or to a group of students (a “collection” in ActiveAdmin).
I am not exactly sure how to model this. My thought is to create a Tag model with one column, where each row is a tag name entered by the admin. So perhaps:
/student.rb class Student < ActiveRecord::Base has_many :tags #student may also have zero tags # rest of model end /tag.rb class Tag < ActiveRecord::Base attr_accessible :name has_and_belongs_to_many :students end
$ rails generate migration create_students_tags_join_table
I’m reading through the rails docs now but suspect the forum may have some insights / corrections / best practices for me in this situation.