如何从rails中删除设计模型?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何从rails中删除设计模型?相关的知识,希望对你有一定的参考价值。
rails aborted!
NameError: uninitialized constant Viewa
/home/pedro/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:268:in `const_get'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:268:in `block in constantize'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:266:in `each'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:266:in `inject'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.7/lib/active_support/inflector/methods.rb:266:in `constantize'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise.rb:316:in `get'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/mapping.rb:83:in `to'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/mapping.rb:78:in `modules'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/mapping.rb:95:in `routes'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/mapping.rb:162:in `default_used_route'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/mapping.rb:72:in `initialize'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise.rb:346:in `new'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise.rb:346:in `add_mapping'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/rails/routes.rb:243:in `block in devise_for'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/rails/routes.rb:242:in `each'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/devise-4.5.0/lib/devise/rails/routes.rb:242:in `devise_for'
/home/pedro/Desktop/Ruby_projects/twitter/config/routes.rb:2:in `block in <top (required)>'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.7/lib/action_dispatch/routing/route_set.rb:391:in `instance_exec'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.7/lib/action_dispatch/routing/route_set.rb:391:in `eval_block'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.7/lib/action_dispatch/routing/route_set.rb:373:in `draw'
/home/pedro/Desktop/Ruby_projects/twitter/config/routes.rb:1:in `<top (required)>'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:40:in `each'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:16:in `reload!'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.7/lib/active_support/file_update_checker.rb:77:in `execute'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:27:in `updater'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application/finisher.rb:119:in `block in <module:Finisher>'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/initializable.rb:30:in `instance_exec'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/initializable.rb:30:in `run'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/initializable.rb:54:in `run_initializers'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application.rb:352:in `initialize!'
/home/pedro/Desktop/Ruby_projects/twitter/config/environment.rb:5:in `<top (required)>'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application.rb:328:in `require_environment!'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/application.rb:448:in `block in run_tasks_blocks'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
/home/pedro/Desktop/Ruby_projects/twitter/bin/rails:9:in `require'
/home/pedro/Desktop/Ruby_projects/twitter/bin/rails:9:in `<top (required)>'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/pedro/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/pedro/Desktop/Ruby_projects/twitter/bin/spring:15:in `require'
/home/pedro/Desktop/Ruby_projects/twitter/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
我不小心创建了一个名为“views”的设计模型,我试图用命令'rails destroy model views'删除它,但现在我无法进行迁移,请帮忙
答案
在你的config/routes.rb
中有device_for
的任何参考,删除它。这应该可以解决这个错误。
当您运行devise生成器时,它会在您的config/routes.rb
文件中生成一些代码,如下所示:
https://github.com/plataformatec/devise/blob/master/lib/generators/devise/devise_generator.rb#L21
另一答案
塔雷克说的话。
如果你使用Git的另一个选择是简单地运行git reset --hard
来清除你的工作树。但是,如果您不关心所做的更改,请仅使用此选项。
另一答案
您是否尝试使用设计生成器删除模型?
$rails destroy devise Viewa
以上是关于如何从rails中删除设计模型?的主要内容,如果未能解决你的问题,请参考以下文章