在写这个问题之前,我查看了这些答案,但无法找到解决方案:
执行rails生成scaffold时出错 用户名:string email:string https://stackoverflow.com/questions/24874678/error-when-execute-rails-generate-scaffold-user-namestring-emailstring
耙子中止! ActiveRecord::Base:Class 的未定义方法“migration_error=” https://stackoverflow.com/questions/18000712/rake-aborted-undefined-method-migration-error-for-activerecordbaseclass
启动 Rails 服务器时出错:未定义方法“配置” https://stackoverflow.com/questions/22977051/error-launching-rails-server-undefined-method-configure
当我尝试启动一个新应用程序时(例如哈特尔的教程 http://www.railstutorial.org/,第 2 章),在该阶段scaffold开始,我收到一个错误,例如:
**undefined method `configure' for #<SampleApp2::Application:0x00000101a74610> (NoMethodError)**
但由于上面的例子,我编辑了开发.rb file:
DemoApp::Application.configure do
(是的,我的应用程序称为demo_app所以我改变了它的名字)。
之后,我尝试跑步scaffold再次但出现新错误:
**method_missing': undefined method raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)**
针对类似案例指出移民方法 - 应将其从文件development.rb 中删除。同样,我试图在这个文件中找到raise_in_transactional_callbacks方法有,但是没有!
另外,我想说的是,在 cmd 中生成的完整代码非常大:
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>'
其中...(省略号)-专门剪掉了类似的代码。
就这样。我将不胜感激任何帮助!