Complete newbie researching Rails. Can Rails be utilized having a read-only schema that does not comply with the Rails' default naming and design conventions?
For instance, my database's schema has base tables which use string posts for unique primary secrets. For instance, basics table known as Jobs, may have a distinctive primary key understood to be Jobs.Job and also the value may be 'D01234'. Now, a young child entity of Jobs may be CostCodes in which the unique primary secret is the aggregate of CostCodes.Job (an FK reference back tothe Jobs table) and CostCodes.CostCode (a nearby string column).
For which it's worth... this is actually the stock Sage Timberline Office database.
Yes, it is possible.
Dork Thomas has a blog post explaining a bit of what's necessary: directives for example
set_table_name "orders" set_primary_key "o_id"
inside your ActiveRecord model definitions.
Searching for "activerecord legacy database" ought to get more.
You are likely to wish to open the Model for the particular table and hang the next:
set_table_name 'user' set_primary_key 'user_name'
And when you're controlling associations you might want to clearly specify the join table:
has_and_belongs_to_many :page, :join_table => 'user_page'
Yes, ActiveRecord (the default ORM) enables you to personalize whatever you have to personalize concerning the database you are being able to access - see Mike's and Robotsu's solutions for particulars.
You may also replace ActiveRecord with another ORM that's more flexible. DataMapper is really a drop-in alternative that appears to possess some traction.
Another solutions already cover your question, but an excellent resource for those these ActiveRecord questions is Professional ActiveRecord by Apress, it is good, you need to look up.