zoukankan      html  css  js  c++  java
  • ruby on rails新项目不使用数据库,配置过程记录

    查询了大神的经验贴

    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 -O
    For existing applications:
    
    1. Remove database adapter gems from your Gemfile (mysql2, sqlite3, etc.)
    
    2. Change your config/application.rb
    
    Remove 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.rb
    
    5. Delete any ActiveRecord configuration from your config/environments files (this is what is causing your error)
    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的依赖也删除
  • 相关阅读:
    内存泄露之LeakCanary原理简析
    springboot(2.3.4)替换默认的logback为log4j2
    springboot-SPI-修改配置文件
    Vue组件
    米尔开发板测试记录
    调试米尔开发板记录
    linux操作GPIO命令
    linux操作PWM命令
    前端缓存(Storage)之有效期
    微信移动端判断二维码识别是否长按
  • 原文地址:https://www.cnblogs.com/iwangzheng/p/4820298.html
Copyright © 2011-2022 走看看