gpt4 book ai didi

ruby-on-rails - 名称错误 : uninitialized constant User

转载 作者:行者123 更新时间:2023-12-04 06:33:53 26 4
gpt4 key购买 nike

我正在将 Rails-devise 应用程序与 Rails Composer 一起使用。在我尝试与控制台中的模型进行交互之前,一切似乎都很好。
我尝试了以下命令:

rails console
User.all

我从控制台收到以下错误:
NameError: uninitialized constant User
from (irb):2
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/console.rb:110:in `start'
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in `start'
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/msarr/Desktop/deployment/YouServe/bin/rails:9:in `<top (required)>'
from /Users/msarr/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/msarr/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'

这是我的 Gemfile:
  source 'https://rubygems.org'
ruby '2.2.1'
gem 'rails', '4.2.5.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'carrierwave'
gem 'mini_magick'
gem 'fog'
gem 'administrate'
gem 'devise'
gem 'devise_invitable'
gem 'foundation-rails', '~> 5.5'
gem 'high_voltage'
gem 'simple_form'

group :development, :test do
gem 'byebug'
gem 'sqlite3'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'better_errors'
gem 'hub', :require=>nil
gem 'quiet_assets'
gem 'rails_layout'
end

group :production do
gem 'pg'
gem 'rails_12factor'
gem 'unicorn'
end

最佳答案

只需重新启动 Spring 加载器。

spring stop

然后运行 ​​ rails c它工作正常

关于ruby-on-rails - 名称错误 : uninitialized constant User,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35616557/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com