# Railroad-database problem

**URL:** <https://www.ruby-forum.com/t/railroad-database-problem/121619>\
**Category:** Rails\
**Created:** [November 29, 2007, 11:48am UTC](https://www.ruby-forum.com/t/railroad-database-problem/121619 "2007-11-29T11:48:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazzybuddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f4b2a3/32.png) [@jazzybuddy](https://www.ruby-forum.com/u/jazzybuddy)\
**Post date:** [November 29, 2007, 11:48am UTC](https://www.ruby-forum.com/t/railroad-database-problem/121619/1 "2007-11-29T11:48:23Z")

</div>

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

development:

database: real\_database

username: schema\_name1

password: \*\*\*\*\*\*\*\*\*\*\*\*

adapter: oracle

abcd\_development:

database: real\_database

username: schema\_name2

password: \*\*\*\*\*\*\*\*\*\*\*\*

adapter: oracle

legacy\_development:

database: real\_database

username: schema\_name3

password: \*\*\*\*\*\*\*\*\*\*\*\*\*\*

adapter: oracle

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

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

reporting.rb  
class Reporting \< ActiveRecord::Base

connection = “legacy\_#{ENV[‘RAILS\_ENV’]}”

establish\_connection connection.to\_sym

end

where ENV[‘RAILS\_ENV’] is development. (configured)

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

xyz.rb

class Xyz \< Reporting

set\_table\_name ‘xyzs’

set\_primary\_key ‘xyz\_id’

end

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

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

1. 

```
              Now I am trying to run the railroad under my

```

application having these database connections.

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

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\_diagram.rb:60:in  
`process\_class’

```
    from /usr/local

```

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

When I exclude this file (reporting.rb), then itz giving another error  
corresponding to the files inheriting the â€œReportingâ€ class like

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’

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

```
                    So how to solve this. Is the behaviour of

```

railroad is like this only or is there any alternative for this.

```
                    Please help me.

                    THNX in advance for the help.

```

Thanks and Regards,

S. Anand.

---

<div class="post-metadata">

**Author:** ![jazzybuddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f4b2a3/32.png) [@jazzybuddy](https://www.ruby-forum.com/u/jazzybuddy)\
**Post date:** [November 29, 2007, 11:57am UTC](https://www.ruby-forum.com/t/railroad-database-problem/121619/2 "2007-11-29T11:57:27Z")

</div>

On 29 Nov 2007, at 10:48, Jazzy B. wrote:

> reporting.rb  
> class Reporting \< ActiveRecord::Base
> 
> connection = “legacy\_#{ENV[‘RAILS\_ENV’]}”
> 
> establish\_connection connection.to\_sym
> 
> end

[snip]

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

I believe this is a pure rails problem. You need to set  
self.abstract\_class = true in the Reporting class so that rails knows  
that there is no matching table.

Fred

---

<div class="post-metadata">

**Author:** ![jazzybuddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f4b2a3/32.png) [@jazzybuddy](https://www.ruby-forum.com/u/jazzybuddy)\
**Post date:** [November 29, 2007, 4:03pm UTC](https://www.ruby-forum.com/t/railroad-database-problem/121619/3 "2007-11-29T16:03:07Z")

</div>

Hi fred,  
Thanks very much for the help… The problem is solved…

Regards,  
Anand.
