未定义的方法 raise_in_transactional_callbacks=' 用于 ActiveRecord::Base:Class (NoMethodError) [英] Undefined method raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)

查看:51
本文介绍了未定义的方法 raise_in_transactional_callbacks=' 用于 ActiveRecord::Base:Class (NoMethodError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在写这个问题之前,我看了这些答案,但找不到解决方案.:

Before writing this question I looked at these answers, but was unable to find a solution.:

执行 rails 生成脚手架时出错 用户名:string email:string

rake 中止!未定义的方法 `migration_error=' 用于 ActiveRecord::Base:Class

启动 Rails 服务器时出错:未定义的方法configure"

当我尝试启动一个新应用程序时(对于 Hartl 的教程,第 2 章),在阶段 scaffold 开始,出现如下错误:

When I try to start a new application (for Hartl's tutorial, Chapter 2), at the stage scaffold start, I got an error like:

**undefined method `configure' for #<SampleApp2::Application:0x00000101a74610> (NoMethodError)**

但是由于上面的例子,我编辑了 development.rb 文件:

But thanks to the above examples, I edited the development.rb file:

DemoApp::Application.configure do

(是的,我的应用程序叫做 demo_app,所以我改变了它的名字).

(Yes, my application is called demo_app so I transformed its name).

在那之后,我尝试再次运行 scaffold 但得到一个新的错误:

After that, I tried to run scaffold again but got a new error:

**method_missing': undefined method raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)**

响应类似情况表明一种迁移方法 - 它应该从文件 development.rb 中删除.同样,我试图在这个文件中找到 raise_in_transactional_callbacks 方法,但它不存在!另外,我会说在cmd中产生的完整代码非常大:

In response to similar cases indicates a migration method - that it should be removed from the file development.rb. Similarly, I tried to find in this file raise_in_transactional_callbacks method, but it's not there! In addition, I would say that the full code that produces in cmd is very large:

C:\Sites\demo_app>rails generate scaffold User name:string email:string
invoke  active_record
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/railtie.rb:166:in `block (3 levels) in <class:Railtie>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/railtie.rb:165:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/railtie.rb:165:in `block (2 levels) in <class:Railtie>'
…
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.2/lib/rails/commands.rb:48:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

凡...(省略号) - 特地剪下类似的代码.就这样.如有任何帮助,我将不胜感激!

Where the ...(ellipsis) - specially cut similar code. That's all. I would be grateful for any help!

推荐答案

你的 config/application.rb 有以下一行:

config.active_record.raise_in_transactional_callbacks = true

这在您的 Rails 版本中不是有效的配置值.您需要将其删除或将其注释掉才能继续.

This is not a valid configuration value in your version of Rails. You will need to delete it or comment it out to continue.

注意:此错误及其之前的错误表明Rails 版本更改.如果您正处于教程的早期阶段,您可能会认真考虑从一开始就使用您喜欢的 Rails 版本重新启动您的应用程序.这将帮助您避免此类错误,直到您更加熟悉该技术.

Note: this error and the one that preceded it are indicative of an incomplete Rails version change. If you are in the early stages of a tutorial, you might seriously consider restarting your application using your preferred version of Rails from the very start. This will help you avoid this type of error until you are more familiar with the technology.

这篇关于未定义的方法 raise_in_transactional_callbacks=' 用于 ActiveRecord::Base:Class (NoMethodError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆