Forum: Ruby on Rails where should I start? If I want to use dataschemas with post

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
14b7344777a56ac9a1fad849f5d6da2a?d=identicon&s=25 sayoyo Sayoyo (sayoyo)
on 2006-02-06 20:06
(Received via mailing list)
Hi,

How should I use Activerecord to map to a database
schemas with Psotgresql? Where can I find the
infomation about how to use schemas in Rails?

Thanks you very much

Saiho



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Ae97ad0da5c7887be291561eb1720093?d=identicon&s=25 Alex Soto (asoto)
on 2006-02-06 21:27
(Received via mailing list)
Saiho Yuen <sayoyo@...> writes:

>
> Hi,
>
> How should I use Activerecord to map to a database
> schemas with Psotgresql? Where can I find the
> infomation about how to use schemas in Rails?
>
Can you give some more details on what you are trying to do?

Are you trying to have one RoR app's set of model objects map to
different db
schemas at the same time :
Blog object maps to schema X
Post object maps to schema Y

or

have different instances(dev, test, qa, integration) of an app map to
different
schemas in the same database?

integration app instance maps to schema INT
qa app instance maps to schema QA

One thing I've done is have a shared integration database, where each
user can
log in with their own db username so they can test in a more complete
environment rather than their own local sandbox which might have alot of
things
mocked out.  Then using postgres' schema search path feature, each
user's db
login's schema is the first in the search path, so when they launch
their app it
connects to their own schema instead of the public schema.

Check out
http://www.postgresql.org/docs/7.4/interactive/ddl...
14b7344777a56ac9a1fad849f5d6da2a?d=identicon&s=25 sayoyo Sayoyo (sayoyo)
on 2006-02-06 22:53
(Received via mailing list)
Hi,

what I'm trying to do is quit simple, we have already
a  database with several different schemas, we try to
build a RoR application on the database, I have
examples about how to map a Activerecords class to a
table, but it doesn't explain how to map a
Activerecords class to a schemas-table. and how should
I configurate database.yml file...

how can we do this?

Thanks you very much

Saiho


--- Alex Soto <apsoto@gmail.com> wrote:

> trying to do?
> of an app map to different
> which might have alot of things
> mocked out.  Then using postgres' schema search path
> feature, each user's db
> login's schema is the first in the search path, so
> when they launch their app it
> connects to their own schema instead of the public
> schema.
>
> Check out
>
http://www.postgresql.org/docs/7.4/interactive/ddl...
>
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Ae97ad0da5c7887be291561eb1720093?d=identicon&s=25 Alex Soto (asoto)
on 2006-02-06 23:30
(Received via mailing list)
Saiho Yuen <sayoyo@...> writes:

>
> how can we do this?

Let's see if I understand you correctly.  Say we have a basic model with
Blogs
and Posts.

In your database:
- you have a schema named blog_app
- you have two tables, blog_app.blogs and blog_app.posts

You can do a number of things, none really requiring any 'special'
database.yml
setup:
- you can create a user named blog_app, then since the user name matches
the
schema name, the default postgres schema search will find the tables in
the
blog_app schema before anything in the public schema
- instead say you have a db login named saiho, then login as saiho via
psql and
set the search path to explicitly:
   SET search_path TO $user,blog_app,public;


I hope that helps
Alex
This topic is locked and can not be replied to.