(This is may be more of a db design question than a rails question.)
I'm thinking of creating a single AR class to hold constant symbol
values and use it for :has_many_through relations whenever I need a
constant symbol. Is this a good idea or a bad idea?
I notice that I have a lot of models that contain just a name string:
create_table "natural_resources", :force => true do |t|
create_table "roles", :force => true do |t|
... etc ...
These moels are always joined through a has_many_through relation to
some other object (e.g. User :has_many :roles, :through => :user_roles),
and the names are treated effectively as constant symbols.
So I'm thinking of consolidating these models into a single one:
create_table :symbols, :force => true do |t|
add_index :symbols, :name, :unique=>true
class Util::Symbol < ActiveRecord::Base
validates :name, :presence => true
(r = where(:name => name.to_s)).create!
... and using this wherever I'd previously used separate classes. This
Can anyone give a strong argument for or against this approach?