rails generate - “Could not find generator”

末鹿安然 提交于 2019-12-23 09:37:04

问题


I am following the Ruby on Rails tutorial by Michael Hartl. In section 6.3.1, I am trying to generate a migration file to add a Password field to my user model. Here is the code that I run:

rails generate add_passsword_digest_to_users password_digest:string

but this throws the error: Could not find generator add_passsword_digest_to_users.

i have used the rails generate command before and it worked perfectly. I'm not sure why I am getting this problem now.

version: Rails 3.2.8, ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


回答1:


Try:

rails generate migration add_passsword_digest_to_users password_digest:string

You simply forgot migration which is the generator to use for the other arguments.




回答2:


You have forget to include migration in the command. You can simply do

rails generate migration add_passsword_digest_to_users password_digest:string


来源:https://stackoverflow.com/questions/12737719/rails-generate-could-not-find-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!