標籤:
查詢了大神的經驗貼
http://stackoverflow.com/questions/19078044/disable-activerecord-for-rails-4
http://stackoverflow.com/questions/821251/how-to-configure-ruby-on-rails-with-no-database
其中點贊最多的也是我用的方法
If you are creating a new application, you can use -O to skip ActiveRecord:rails new my_app -OFor existing applications:1. Remove database adapter gems from your Gemfile (mysql2, sqlite3, etc.)2. Change your config/application.rbRemove require ‘rails/all line and require frameworks you want to use, for example:require "action_controller/railtie"require "action_mailer/railtie"require "sprockets/railtie"require "rails/test_unit/railtie"3. Delete your config/database.yml file, db/schema.rb and migrations (if any)4. Delete migration check in test/test_helper.rb5. Delete any ActiveRecord configuration from your config/environments files (this is what is causing your error)
這一步直接刪除environments裡所有的檔案This is all you need to do for an empty Rails app. If you run into problems caused by your existing code, stack trace should give you sufficient information on what you need to change. You might for example have some ActiveRecord configuration in your initializers.
6.刪除controller裡對Model的調用,把model裡對ActiveRecord的依賴也刪除
ruby on rails新項目不使用資料庫,配置過程記錄