Disable ActiveRecord in Ruby on Rails 5

99封情书 提交于 2020-01-23 02:41:54

问题


I am a newbie in Rails.

I want to disable ActiveRecord in Rails 5.

I've already found several answers Here, Here and Here

But none of them seems working for me.

Would you help me with this issue, please?

Thanks.


回答1:


Accepted answer in this post of mechanicalfish is right.

But in my case, I've done following 2 additional things (I've used Rails 5.1.2)

Delete model files in models directory

models/application_record.rb

models/widget.rb

Hope this helps!




回答2:


Just to update, there is no need to delete anything by hand if you are using Rails 5 or greater.

For new rails application in Rails version 5 or newer, all of these are handled. Just run the rails new command with -O (--skip-active-record) argument.

> rails new proj_no_db -O

For api only Rails application without DB,

> rails new proj_api_no_db -O --api



回答3:


Just comment database in database.yml and it will be working. Tested in rails 5.2

 username: root
 password: anyPass
 #database: db_name


来源:https://stackoverflow.com/questions/45008990/disable-activerecord-in-ruby-on-rails-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!