问题描述
我创建了一个带有上述选项的 Rails 3 项目.我可以以某种方式还原"此选项并将活动记录恢复为默认值,还是必须创建一个新项目?
I have created a Rails 3 project with mentioned option. Can I somehow "revert" this option and have active record back as in default, or must I create a new project?
编辑
好的,要获得 ActiveRecord 支持,我必须:
Ok, to have ActiveRecord support back I had to:
- 删除
application.rb
中单独的 require 调用并将其替换为require 'rails/all'
(或者只是取消注释# require "active_record/railtie"
) - 取消注释
# gem 'sqlite3-ruby', :require =>Gemfile 中的 'sqlite3'
行(用于 sqlite) - 创建 database.yml 文件并用选项填充它
- 调用
rake db:create
任务
- Delete separate require calls in
application.rb
and replace it withrequire 'rails/all'
(or just uncomment# require "active_record/railtie"
) - Uncomment
# gem 'sqlite3-ruby', :require => 'sqlite3'
line in Gemfile (for sqlite) - Create database.yml file and fill it with options
- invoke
rake db:create
task
在那之后,我似乎可以像往常一样继续使用 AR.
After that it seems that I can continue to work with AR as usual.
推荐答案
用 ActiveRecord 创建一个新项目,然后成对 diff config/application.rb
和 config/environments/*.rb
以确定是否有任何默认设置您应该添加回您的项目.
Make a new project with ActiveRecord, and then pairwise diff config/application.rb
and config/environments/*.rb
to determine if there are any default settings you should add back to your project.
这篇关于在 rails 3 中使用 --skip-active-record 选项创建项目后恢复 AR 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!