Heroku只初始化了我的一些模型

时间:2010-12-27 17:39:21

标签: ruby-on-rails sqlite heroku

所以我跑了

 heroku db:push

它又回来了

 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

当我去

  heroku console

这有效

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

这有效

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

但其他人只返回了类似

的内容
 >> 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'

更新1:

当我输入

  >> ActiveRecord::Base.connection.tables

它返回了

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

使用heroku的SQL控制台插件

我得到了

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

所以我认为它们已经存在于heroku的数据库中。

rack db:migrate

可能有问题

更新2:

我运行机架db:在生产和开发模式下本地迁移,没有发生任何错误。

但是当我在heroku上运行时 它只返回:

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

另外,我正在使用sqlite3

更新3:

所以我打开了heroku控制台并键入以下命令

class Authentication < ActiveRecord::Base;end

令人惊讶的是我能够调用身份验证类,但是一旦我退出,没有任何改变。

3 个答案:

答案 0 :(得分:2)

您将其显示为pojects并显示authenticato

另外,你有没有重新启动应用程序吗?

哦,你已经提交了git中的文件并且我也希望做到正常git push heroku master

你只是继续谈论heroku db:push我几乎没有在日常提交中使用该命令。

答案 1 :(得分:2)

此错误:

 >> Project  
   NameError: uninitialized constant Project

表示缺少Project模型,这不属于数据库。

尝试:

git add .  
git commit -am 'update'
git push heroku master

答案 2 :(得分:1)

如果你实际上错过了SQLite中的表,你会看到像Project(Table doesn't exist)

这样的错误