What are the best practices in case you want to build a Rails project that uses an existing Database?
in my case the postgres database living on a remote machine that runs a docker instance with postgres has a database with a table stake_address
.
Now I have created a model in Rail:
class StakeAddress < ApplicationRecord
end
in rails console
:
2.6.1 :001 > StakeAddress.all
Traceback (most recent call last):
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "stake_addresses" does not exist)
LINE 1: SELECT "stake_addresses".* FROM "stake_addresses" LIMIT $1
^
is there a way to avoid Rails to look for a pluralised table?
I suppose there are going to be many other problems like this, so I was wondering if this is common practice, or if is something out of the world that is highly recommended to avoid?
Also I guess I don't need migrations, because the database is already created. Is that going to cause problems down the line?
My idea is that I will be able to connect to two databases, one read-only already existing and the other one where I can put my own models as Users. But will they be able to create association cross databases?
Perhaps Rails isn't the best framework for this type of work? Is what I am learning during a bootcamp, but perhaps I should switch to more flexible environments?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…