生成漂亮时出错:scaffold=> create_migration':参数数量错误(3 代表 0)(ArgumentError`)

Posted

技术标签:

【中文标题】生成漂亮时出错:scaffold=> create_migration\':参数数量错误(3 代表 0)(ArgumentError`)【英文标题】:error while generating nifty:scaffold=> create_migration': wrong number of arguments (3 for 0) (ArgumentError`)生成漂亮时出错:scaffold=> create_migration':参数数量错误(3 代表 0)(ArgumentError`) 【发布时间】:2014-08-11 00:47:07 【问题描述】:

在尝试创建脚手架时 rails g nifty:scaffold authentication user_id:integer provider:string uid:string index create destroy

authentication.rb 已生成,但没有视图 我收到错误 /home/user/.rvm/gems/ruby-2.1.0/gems/nifty-generators-0.4.6/lib/generators/nifty/scaffold/scaffold_generator.rb:85:in create_migration': wrong number of arguments (3 for 0) (ArgumentError) from /home/user/.rvm/gems/ruby-2.1.0/gems/railties-4.1.2.rc1/lib/rails/generators/migration.rb:63:inmigration_template' 来自/home/user/.rvm/gems/ruby-2.1.0/gems/nifty-generators-0.4.6/lib/generators/nifty/scaffold/scaffold_generator.rb:87:in create_migration' from /home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:inrun' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command' from /home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:inblock in invoke_all' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in each' from /home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:inmap' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in invoke_all' from /home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/group.rb:232:indispatch' 来自/home/user/.rvm/gems/ruby-2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start' from /home/user/.rvm/gems/ruby-2.1.0/gems/railties-4.1.2.rc1/lib/rails/generators.rb:157:ininvoke' 来自/home/user/.rvm/gems/ruby-2.1.0/gems/railties-4.1.2.rc1/lib/rails/commands/generate.rb:11:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:247:inrequire' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:247:in block in require' from /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:232:inload_dependency' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:247:in require' from /home/user/.rvm/gems/ruby-2.1.0/gems/railties-4.1.2.rc1/lib/rails/commands/commands_tasks.rb:135:ingenerate_or_destroy' 来自/home/user/.rvm/gems/ruby-2.1.0/gems/railties-4.1.2.rc1/lib/rails/commands/commands_tasks.rb:51:in generate' from /home/user/.rvm/gems/ruby-2.1.0/gems/railties-4.1.2.rc1/lib/rails/commands/commands_tasks.rb:40:inrun_command!' 来自/home/user/.rvm/gems/ruby-2.1.0/gems/railties-4.1.2.rc1/lib/rails/commands.rb:17:in <top (required)>' from /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:247:inrequire' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:247:in block in require' from /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:232:inload_dependency' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:247:in require' from /home/user/Desktop/remake/bin/rails:8:in' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:241:in load' from /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:241:inblock in load' 来自 /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:232:in load_dependency' from /home/user/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.2.rc1/lib/active_support/dependencies.rb:241:inload' 来自 /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in require' from /home/user/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:inrequire' 从 -e:1:in `'

【问题讨论】:

【参考方案1】:

Nifty 生成器自 2012 年 10 月以来一直没有更新(来自 github 页面)。使用不同的东西,因为这个 gem 肯定不是最新的。

【讨论】:

哪种 gem 更适合进行身份验证?我想使用 facebook 的注册和正常使用omniauth 并同时设计 @user3710415 正如你所说,设计和omniauth将满足你的需求 我想在同一张桌子上同时使用它们 @user3710415 使用 devise 生成 users 表,然后创建迁移以添加 uid、provider。有关设计,请参阅 here,对于 Facebook 示例,请查看 this @user3710415 我认为这里不适合详细说明。为了让您抢先一步,您必须在您的应用程序中安装设计,然后安装 rails generate devise:install rails generate devise MODEL,然后按照链接中给出的步骤进行操作。 :) 自己尝试一些东西,这就是你学习的方式,如果你有任何错误,你可以将它们作为问题发布。 :)

以上是关于生成漂亮时出错:scaffold=> create_migration':参数数量错误(3 代表 0)(ArgumentError`)的主要内容,如果未能解决你的问题,请参考以下文章

搭建第一个Dapp应用——基于SmartDev-Scaffold生成SpringBoot项目——2021.5.3

Rails:当模型已经存在时,如何运行`rails generate scaffold`?

EFCore Scaffold-DbContext 可以生成自定义模型名称吗?

生成 <DbContext> 时出错

vs2008编译成功,生成mt.exe时出错

准备 CoreML 模型时出错:CoreML 代码生成不支持“<something>”