我正在学习如何使用Ruby on Rails, 上次我尝试为用户制作脚手架。
rails generate scaffold user first_name:string last_name:string
出于某种原因,它不会起作用。 我先得到一条消息,然后几秒钟后发出一条相当大的消息。
第一条错误消息:
C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/values/time_zone.rb:282:
warning: circular argument reference - now invoke active_record
第二条消息:
C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:58:in rescue in resolve_hash_connection: Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'mysql2' to your Gemfile. (Gem::LoadError)
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/connection_specification.rb:30:in `spec'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:39:in `establish_connection'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/railtie.rb:176:inblock (2 levels) in `class:Railtie'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:45:in block in `run_load_hooks'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:44:in `each'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/base.rb:322:in `module:ActiveRecord'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/active_record/base.rb:22:in `<top (required)>'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in block in `require'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.0.2/lib/rails/generators/named_base.rb:172:in `pluralize_table_names?'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.0.2/lib/rails/generators/named_base.rb:112:in `table_name'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-4.0.2/lib/rails/generators/active_record/model/model_generator.rb:18:in `create_migration_file'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in block in `invoke_all'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:277:in block in `_invoke_for_class_method'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/shell.rb:68:in `with_padding'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:266:in `_invoke_for_class_method'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:133:in `_invoke_from_option_orm'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.0.2/lib/rails/generators.rb:156:in `invoke'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.0.2/lib/rails/commands/generate.rb:11:in `'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in block in `require'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from C:/row/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.0.2/lib/rails/commands.rb:48:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `''
答案 0 :(得分:0)
请尝试将mysql2
gem添加到Gemfile
,然后运行命令bundle install
。我认为这应该有用。