gpt4 book ai didi

ruby-on-rails - Rails 4 生成设计 View

转载 作者:行者123 更新时间:2023-12-04 02:48:23 25 4
gpt4 key购买 nike

我想为应用程序生成一些设计 View ,但每当我尝试使用命令 rails g devise:views 时,我都会遇到一个复杂的错误,远远超出我的理解。

/Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007ff613f5bb10 @paths=["/Users/michaeldunnegan/projects/SoundShare/config/routes.rb"], @route_sets=[#<ActionDispatch::Routing::RouteSet:0x007ff6168369e0>]> (RuntimeError)
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/michaeldunnegan/projects/SoundShare/config/environment.rb:4:in `<top (required)>'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:45:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

其中一行,/Users/michaeldunnegan/projects/SoundShare/config/environment.rb:4:in'`

很有趣。我在那个文件中只有:

# Load the Rails application.
require File.expand_path('../application', __FILE__)

SoundShare::Application.initialize! # this is the line

最佳答案

  1. 确保你的 devise gem 兼容 rails 4 gem 'devise', '~> 3.0.0.rc' #or higher

  2. 运行包更新

  3. 删除 initializers 中的 devise.rb,然后再次运行 devise:install 以在初始化器中安装新配置。

  4. 确保运行 devise 模型生成器,例如 rails g devise User

  5. 现在您应该可以运行:rails g devise:views

编辑

在 Mike 的计算机上使用 teamviewer 后,我们从 rails 4 上的一个工作项目中获取了 devise.rb 的副本,并将其放置在 config/initializers/

接下来我们运行了 rails generate devise:install 命令,它返回了一些关于弃用的信息,并询问我们是否要替换 devise.rb 文件的内容.我们接受了它,此后所有设计命令都运行良好。

关于ruby-on-rails - Rails 4 生成设计 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18344517/

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