Ruby、Rake、Mysql - 创建数据库
怎么办? 我尝试了类似的操作:
RAILS_ENV=production rake db:create db:load
在文件 /lib/tasks/load_tasks.rake
中,并且我在终端中尝试将此文件作为 rake db:migrate
,但我收到有关语法等的错误我
在终端中输入了这个命令(我在教程中看到了它):
rails generate scaffold Account user_name:string description:text premium:boolean \
income:integer ranking:float fee:decimal birthday:date login_time:time
这使我创建了文件 20110518181941_create_accounts.rb
我如何创建数据库表 - 我认为该命令上面将在 mysql 中创建我的数据库...我现在有点困惑,该怎么办?
rake db:migrate
这里使用什么规则?
How to do?
I tried something like:
RAILS_ENV=production rake db:create db:load
in file /lib/tasks/load_tasks.rake
and this file I tried in terminal as rake db:migrate
, but I am getting errors about syntax etc.
I entered into terminal this command (I saw it in tutorial):
rails generate scaffold Account user_name:string description:text premium:boolean \
income:integer ranking:float fee:decimal birthday:date login_time:time
And this made me file 20110518181941_create_accounts.rb
How can I create database table - I thought the command above will create me database in mysql... I am now a bit confusing, what to do?
Which rule is playing here rake db:migrate
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您收到此错误是因为您的语法错误,请将
&&
放在句子之间:或者分行执行
第一个命令将创建数据库,第二个命令将加载 <将 code>db/schema.rb 文件写入数据库
最后,您需要运行迁移:
创建您的 Accounts 表。
顺便说一句,如果你运行:
你可以看到 rake 任务列表及其描述。
希望这有帮助。
I think you are getting this error because your syntax is wrong, please put
&&
between sentences:or do it in separated lines
the first command will create the database, the second command will Load the
db/schema.rb
file into the databaseAnd finally you need to run your migration:
to create your Accounts table.
BTW if you run:
you can see the list of rake tasks and their descriptions.
Hope this helps.