I need to build a Ruby on Rails database which c开发者_如何学编程an handle multiple “modules” which provide various related sets of functionality. I'd like some way of grouping the module tables by their modules, almost akin to namespaces.
Is the :
character safe for use in table names with Ruby on Rails, and if not, what's a good alternative?
That really depends on the database provider. If you're using mysql or some other sql based database, I'd say that : isn't permitted, but what you can do is modify the migration file to name the table something like modulename_modelname. Then in the model itself you can specify the table name by calling set_table_name as documented here:
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-set_table_name
That just looks dangerous and ugly to me. I'd stick with prepending something with underscores.
admin_users
admin_tools
supervisor_charts
etc
精彩评论