Heroku only initializes some of my models.

Posted by JayX on Stack Overflow See other posts from Stack Overflow or by JayX
Published on 2010-12-27T17:39:21Z Indexed on 2010/12/28 1:54 UTC
Read the original article Hit count: 206

Filed under:
|
|

So I ran

 heroku db:push

And it returned

 Sending schema
 Schema:        100% |==========================================| Time: 00:00:08
 Sending indexes
 schema_migrat: 100% |==========================================| Time: 00:00:00
 projects:   100% |==========================================| Time: 00:00:00
 tasks:         100% |==========================================| Time: 00:00:00
 users:         100% |==========================================| Time: 00:00:00
 Sending data
 8 tables, 70,551 records
 groups:        100% |==========================================| Time: 00:00:00
 schema_migrat: 100% |==========================================| Time: 00:00:00
 projects:   100% |==========================================| Time: 00:00:00
 tasks:         100% |==========================================| Time: 00:00:02
 authenticatio: 100% |==========================================| Time: 00:00:00
 articles:       100% |==========================================| Time: 00:08:27
 users:         100% |==========================================| Time: 00:00:00
 topics:        100% |==========================================| Time: 00:01:22
 Resetting sequences

And when I went to

  heroku console

This worked

  >> Task
  => Task(id: integer, topic: string, content: string,

This worked

 >> User
  => User(id: integer, name: string, email: string,

But the rest only returned something like

 >> Project
   NameError: uninitialized constant Project
/home/heroku_rack/lib/console.rb:150
/home/heroku_rack/lib/console.rb:150:in `call'
/home/heroku_rack/lib/console.rb:28:in `call'


>> Authentication
  NameError: uninitialized constant Authentication
/home/heroku_rack/lib/console.rb:150
/home/heroku_rack/lib/console.rb:150:in `call'

update 1:

And when I typed

  >> ActiveRecord::Base.connection.tables

it returned

   => ["projects", "groups", "tasks", "topics", "articles", "schema_migrations", "authentications", "users"]

Using heroku's SQL console plugin

I got

 SQL> show tables
 +-------------------+
 |    table_name     |
 +-------------------+
 | authentications   |
 | topics            |
 | groups            |
 | projects          |
 | schema_migrations |
 | tasks             |
 | articles          |
 | users             |
 +-------------------+

So I think they are existing in heroku's database already.

There is probably something wrong with rack db:migrate

update 2:

I ran rack db:migrate locally in both production and development modes and nothing wrong happened.

But when I ran it on heroku it only returned:

  $ heroku rake db:migrate
 (in /disk1/home/slugs/389817_1c16250_4bf2-f9c9517b-bdbd-49d9-8e5a-a87111d3558e/mnt)
  $

Also, I am using sqlite3

update 3:

so I opened up heroku console and typed in the following command

class Authentication < ActiveRecord::Base;end

Amazingly I was able to call Authentication class, but once I exited, nothing was changed.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about sqlite3