Heroku 只初始化我的一些模型

发布于 2024-10-09 11:54:39 字数 3092 浏览 1 评论 0原文

所以我跑了

 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:

我在生产和开发模式下都在本地运行了rack db:migrate,没有发生任何错误。

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

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

另外,我正在使用 sqlite3

update 3:

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

class Authentication < ActiveRecord::Base;end

惊讶的是我能够调用 Authentication 类,但是一旦退出,什么都没有改变。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋千易 2024-10-16 11:54:40

此错误:

 >> Project  
   NameError: uninitialized constant Project

表示项目模型丢失,这不属于数据库。

尝试:

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

This error:

 >> Project  
   NameError: uninitialized constant Project

means that Project model is missing, this is not belongs to the database.

try:

git add .  
git commit -am 'update'
git push heroku master
哥,最终变帅啦 2024-10-16 11:54:40

你称它为pojects,它出现并且authenticato

另外,你已经heroku重新启动了应用程序,对吧?

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

你只是一直在谈论heroku db:push,我在日常提交中几乎从不使用该命令。

you called it pojects it appears and authenticato

Also, you've heroku restarted the app right?

Oh, and you have commited the files in git and did a normal git push heroku master i hope as well?

you just keep talking about heroku db:push which i hardly ever use that command in day to day commits.

扮仙女 2024-10-16 11:54:40

如果您实际上缺少 SQLite 中的表,您会看到类似 Project(Table does not exit) 的错误

If you were actually missing the Tables in SQLite you would see an error like Project(Table doesn't exist)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文