Config Rails 3.0 without Database

    技术2022-05-20  112

    Sometimes we maybe just need some simple work with rails, database configuration is optional. We can just config rails without db config.

     

    These following can be applied to rails 3.0.

    original link, http://stackoverflow.com/questions/2212709/remove-activerecord-in-rails-3-beta

     

    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.rb doesn't have require 'rails/all' or require "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 the config.generators section, make sure it doesn't have the line g.orm :active_record . You can set this explicitly to nil , if you want, but this should be the default when g.orm is completely omitted.

    Optional, but in your Gemfile , remove the gem line that loads the module for your database. This could be the line gem "mysql" for example.


    最新回复(0)