Table names are not properly quoted in many parts of ActiveRecord. This causes several problems when working with legacy databases (using non-rails standard naming conventions).
Example:
class Something < ActiveRecord::Base
set_table_name 'Legacy Database'
validates_presence_of :name
end
i = Something.new(:name => 'Something')
i.valid? # => Exception (table name not quoted in where clause): SELECT * FROM `Legacy Database` WHERE (Legacy Database.value = 1000) LIMIT 1
Something.update_all(:name => 'Something') # => Exception: UPDATE Legacy Database SET name = 'Something'
One aspect of this problem is covered in #10599, but there are seem to be many more (especially in the Associations component).
I put together a patch which should fix the known problems (but more might come up).
Dimitrij