I'm going by this from reading the source, so let me know if it actually worked. :)
The rails
command that generates the application template now has an option -O
, which tells it to skip ActiveRecord.
If you don't feel like rerunning rails
, you should check the following in your existing app:
-
Check that your
config/application.rbdoesn't haverequire 'rails/all'orrequire "active_record/railtie". Instead, for a standard Rails setup without ActiveRecord, it should have only the following requires:require File . expand_path ( '../boot' , __FILE__ )
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
# Auto-require default libraries and those for the current Rails environment.
Bundler . require : default , Rails . env
-
If, in
config/application.rb, you are using theconfig.generatorssection, make sure it doesn't have the lineg.orm :active_record. You can set this explicitly tonil, if you want, but this should be the default wheng.ormis completely omitted. -
Optional, but in your
Gemfile, remove thegemline that loads the module for your database. This could be the linegem "mysql"for example.
本文介绍如何在Ruby on Rails 3.0中移除ActiveRecord,实现不需要数据库配置的应用程序。主要内容包括:使用命令行选项跳过ActiveRecord的加载、修改config/application.rb文件中的依赖项以及在Gemfile中移除数据库相关gem。
103

被折叠的 条评论
为什么被折叠?



