[英]“rails generate model” hangs
I'm new to ROR. 我是ROR的新手。
How can I use the same App name after I delete my rails App? 删除rails应用程序后,如何使用相同的App名称?
Following are the actions I performed. 以下是我执行的操作。 Step #6 is my problem. 第6步是我的问题。
1 - Environment 1 - 环境
- OS : Ubuntu 12.04.4
- ruby : 2.1.1p76
- rails : 4.1.2
- DB : SQLite
2 - Create rails App : 2 - 创建rails App:
rails new myApp
=> OK
3 - Create model : 3 - 创建模型:
rails generate model mytable name:string
=> OK.
4 - Delete rails App : 4 - 删除rails App:
rm -rf myApp
=> OK
5 - Re-Create rails App : 5 - 重新创建rails App:
rails new myApp
=> OK
6 - Re-Create model : 6 - 重新创建模型:
rails generate model mytable name:string
=> Not OK! waiting for infinite time
Just a hunch, but by any chance, are you still running a server process somewhere on your machine? 只是预感,但无论如何,你还在机器的某个地方运行服务器进程吗? That could be holding a lock that is preventing the new table from getting built. 这可能是一个阻止新表被构建的锁。
Follow below steps 按照以下步骤
1 - Create rails App : 1 - 创建rails App:
rails new myApp
2 - Create model : 2 - 创建模型:
rails generate model mytable name:string
3 - Drop The database : 3 - 删除数据库:
rake db:drop
4 - Delete rails App : 4 - 删除rails App:
rm -rf myApp
5 - Re-Create rails App : 5 - 重新创建rails App:
rails new myApp
6 - Recreate Database 6 - 重新创建数据库
rake db:create
7 - Re-Create model : 7 - 重新创建模型:
rails generate model mytable name:string
I think your database still has the table corresponding to your model from the first time you created it. 我认为从您第一次创建数据库时,您的数据库仍然具有与您的模型对应的表。 What database system are you using? 您使用的是什么数据库系统? Performing rm -rf
does not generally affect the database since the data lives outside the Rails app directory. 执行rm -rf
通常不会影响数据库,因为数据位于Rails应用程序目录之外。 You may need to reset the database with 您可能需要使用重置数据库
$ rake db:reset
This will delete the table that was left over from the first time you created the model. 这将删除您第一次创建模型时遗留的表。
Note: If you are using SQLite for your database, this may point to a different problem. 注意:如果您使用SQLite作为数据库,这可能会指向另一个问题。
不要杀死弹簧,只需使用内置的spring stop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.