On Tuesday, 3 April 2012 13:32:54 UTC-4, Ruby-Forum.com User wrote:
>
> (This is may be more of a db design question than a rails question.)
>
> Summary:
>
> 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?
>
>
> Given your examples, I'm not convinced all of the things even need to BE 
in the database. One question I'd ask to help decide this is, "can an 
end-user meaningfully add a new one of these through the web interface?"

For example, "roles" typically would NOT be meaningful to add from the web 
interface - they require additional plumbing (unless you've got serious 
DB-driven RBAC already) in code above and beyond a simple name.

On the other hand, "categories" on a blog are a classic example of 
something that belongs in the DB; there's no additional behavior expected, 
they're just labels that can be attached to other things.

As to your original question, I'd lean towards "bad idea" - as others have 
pointed out, if the items in question are supposed to operate in separate 
domains they should be kept separate. This winds up simplifying lots of 
stuff - for instance, I can't think of any reason one would want to display 
a drop-down with a mishmash of natural resources and user roles, but a list 
of one or the other makes sense.

If you're really just looking for the ability to attach context-sensitive 
labels, you may also want to look at acts_as_taggable_on and friends:

https://github.com/mbleigh/acts-as-taggable-on

which will do nearly all of the work for you.

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/9KYl2lVG9JMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to