Forum: Ruby on Rails how to generate third table in test database

Posted by fahim patel (fahim_patel)
on 2012-09-12 09:58
(Received via mailing list)
hi all,

  has_and_belongs_to_many :cows
  has_and_belongs_to_many :milkmans

i am using  has_and_belongs_to_many  in my app.I know this will create
third table internally cows_milkmans in mysql database.

when i migrate develpoment database i  have table cows_milkmans. Good no
Problem till now.

Now a problem start When i migrate test database there is no
such cows_milkmans table is present..
And we all know that   has_and_belongs_to_many not generate any migrate
file.

What should i do now?
how to generate third table in test database ?
If there is no solution than i know that i have to create  cows_milkmans
table  manually .

Thanks
Fahim Babar Patel
Posted by Colin Law (Guest)
on 2012-09-12 10:54
(Received via mailing list)
On 12 September 2012 08:57, Fahim Patel <pafahim@gmail.com> wrote:
>
> Now a problem start When i migrate test database there is no such
> cows_milkmans table is present..
> And we all know that   has_and_belongs_to_many not generate any migrate
> file.
>
> What should i do now?
> how to generate third table in test database ?
> If there is no solution than i know that i have to create  cows_milkmans
> table  manually .

There is no need to run migrate on the test db.
rake db:test:prepare
will create or update the test database to the same state as the 
development db.

Colin
Posted by Colin Law (Guest)
on 2012-09-12 11:00
(Received via mailing list)
On 12 September 2012 09:53, Colin Law <clanlaw@googlemail.com> wrote:
>> Problem till now.
>
> There is no need to run migrate on the test db.
> rake db:test:prepare
> will create or update the test database to the same state as the development db.

Also have a look at the Rails Guide on Testing for more information.

Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.