I have a model which may be associated with zero or more static values. For example, movies and genres (horror, action, etc.) I want to make an genres
array on my model but I'm not sure the best way to reflect this in the database.
I am using Rails/AR 4 and Postgres along with the pg_search
gem.
I can go the classic route of creating a genres
table and creating a join table between the two. However, this seems a little bit like overkill because genres
do not change very often.
I could create a genre
enum type and then create an array of genre
s on the the model but I'm not sure how well Active Record supports this sort of mechanism.
I will need to be able to search for movies based on genre as well as other criteria (keyword, length, rating, etc.)
Any best practices and/or resources would be greatly appreciated. Am I missing a simpler or more straight forward solution? Do any of the above fail to solve my problem in a way I am not anticipating?