[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

railroad-database problem

srinivasan.anand

11/29/2007 10:28:00 AM

Hi all,

I am facing with a new type of problem with railroad,
explained below

=20

1. I am using an oracle database in my application. In
the database.yml file, I am having different schema connections to the
same database.like

=20

development:

database: real_database

username: schema_name1

password: ************

adapter: oracle

=20

abcd_development:

database: real_database

username: schema_name2

password: ************

adapter: oracle

=20

legacy_development:

database: real_database

username: schema_name3

password: **************

adapter: oracle

=20

u can observe that only the usernames/schemas are different but the
database is the same for all the connections.=20

=20

And according to the rails-database conventions when defining multiple
connections in database.yml, we have to create separate models for each
of the connections like

=20

reporting.rb

class Reporting < ActiveRecord::Base

connection =3D "legacy_#{ENV['RAILS_ENV']}"

establish_connection connection.to_sym

end=20

=20

where ENV['RAILS_ENV'] is development. (configured)

=20

and suppose that there is a table xyz under this schema (schema_name3),
then I have to inherit from this class and define the model for the xyz
table like

=20

xyz.rb

class Xyz < Reporting

set_table_name 'xyzs'

set_primary_key 'xyz_id'

end

=20

so whenever the xyz table is called, it automatically connects to the
legacy_development connection and proceeds. Right ??

=20

This is the scenario. (Hope my understanding is proper...!@#$#)

=20

=20

2. Now I am trying to run the railroad under my
application having these database connections.=20

=20

I think , what is happening is, the railroad is trying to find a table
named reportings , but Reporting is just the connecting model for the
legacy_development connection. The error which I am getting is=20

=20

R09222:~/project1> railroad -M models

(eval):3:in `describe': "DESC reportings" failed; does it exist?
(RuntimeError)

from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/
connection_adapters/oracle_adapter.rb:316:in `columns'

from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/
base.rb:763:in `columns'

from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/
base.rb:782:in `content_columns'

from
/usr/local/lib/ruby/gems/1.8/gems/railroad-0.4.0/lib/railroad/models_dia
gram.rb:60:in `process_class'

from /usr/local

=20

So It is clear that it is trying to find a table named reportings under
this schema.=20

=20

When I exclude this file (reporting.rb), then itz giving another error
corresponding to the files inheriting the "Reporting" class like=20

=20

railroad -M -e reporting.rb models

/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support
/dependencies.rb:266:in `load_missing_constant': uninitialized constant
Reporting (NameError)

from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support
/dependencies.rb:452:in `const_missing'

from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support
/dependencies.rb:464:in `const_missing'

from ./app/models/xyz.rb:1

from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'

=20

=20

How to make railroad understand that reporting.rb is not a table but
just a connection.

=20

So how to solve this. Is the behaviour of
railroad is like this only or is there any alternative for this.=20

Please help me.=20

=20

THNX in advance for the help.

=20

=20

Thanks and Regards,

S. Anand.



This message is for the designated recipient only and may contain =
privileged, proprietary, or otherwise private information. If you have =
received it in error, please notify the sender immediately and delete =
the original. Any other use of the email by you is prohibited.

3 Answers

Luis Lavena

11/29/2007 6:34:00 PM

0

On Nov 29, 7:28 am, srinivasan.an...@accenture.com wrote:
> Hi all,
>
> I am facing with a new type of problem with railroad,
> explained below
>
> 1. I am using an oracle database in my application. In
> the database.yml file, I am having different schema connections to the
> same database.like
>

Can you first try your success accessing your classes from script/
console ?

You're trying to get too many things in one row, and sometimes you
missed the spot.

Tryo from the console grabbing the model information, and if it works
_then_ look for problems in railroad.

....
>
> How to make railroad understand that reporting.rb is not a table but
> just a connection.
>

Reporting in a table, why then is inside app/models? and inherit from
ActiveRecord::Base ?

Ilan Berci

11/29/2007 9:11:00 PM

0

unknown wrote:
> Hi all,
>
> I am facing with a new type of problem with railroad,
> explained below
>
>
>
> 1. I am using an oracle database in my application. In
> the database.yml file, I am having different schema connections to the
> same database.like
>
>
>
A database can only have one schema definition from a rails perspective.

From the configuration file it appears that you are attempting to have
different users access the same db with different privilege sets. If
this is the case, then make sure that both users can see the "Reporting"
table.

Secondly, as suggested earlier, you should check the console to make
sure that you indeed have a table named: "reportings"..

Lastly, please post rails or "railroad" related questions to the rails
forum.

hth

ilan



--
Posted via http://www.ruby-....

srinivasan.anand

11/30/2007 12:29:00 PM

0

Hi,
Thanks for the valuble help. I have anyhow solved the problem.
The problem was that, as I have correctly guessed the rails was
expecting a reportings table. But I need to tell the rails that
reportings is not a table, but only a connection. I did that by
including the line "self.abstract_class=3D>true" in the reportings.rb =
file
so that the rails does not expect a table out of it.

Thanks and Regards,
S. Anand.

-----Original Message-----
From: list-bounce@example.com [mailto:list-bounce@example.com] On Behalf
Of Ilan Berci
Sent: Friday, November 30, 2007 2:41 AM
To: ruby-talk ML
Subject: Re: railroad-database problem

unknown wrote:
> Hi all,
>=20
> I am facing with a new type of problem with railroad,
> explained below
>=20
>=20
>=20
> 1. I am using an oracle database in my application.
In
> the database.yml file, I am having different schema connections to the
> same database.like
>=20
>=20
>=20
A database can only have one schema definition from a rails perspective.

From the configuration file it appears that you are attempting to have=20
different users access the same db with different privilege sets. If=20
this is the case, then make sure that both users can see the "Reporting"

table.

Secondly, as suggested earlier, you should check the console to make=20
sure that you indeed have a table named: "reportings"..

Lastly, please post rails or "railroad" related questions to the rails=20
forum.

hth

ilan



--=20
Posted via http://www.ruby-....



This message is for the designated recipient only and may contain =
privileged, proprietary, or otherwise private information. If you have =
received it in error, please notify the sender immediately and delete =
the original. Any other use of the email by you is prohibited.