Вопрос

I need to add a new user to my app's Postgres User table located in the test schema. When I access the console, rails automatically sets the search path to "$user",public and the new user record is saved to the public schema, not the test schema. Is there a way to add records to the User table within the test schema using the console?

Это было полезно?

Решение

rails automatically sets the search path to

No, it's not Rails - it's Postgres doing that. It's the default search path defined in Postgres. See the manual for details: http://www.postgresql.org/docs/current/static/ddl-schemas.html#DDL-SCHEMAS-PATH

If you want a different search path for that user, use alter user to change the user's search path, e.g.:

alter user foo set search_path = 'public';

Другие советы

I don't think that the rails-console is very well suited to do administrative tasks. You are also specifying the schema in the database.yaml I guess you would need to create a new connection in your console.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top