0

I want to create a rails project in which I won't need a database.

I like to do things in a clean way, without leaving traces behing, so I thought I'd remove all db-like gems from the project.

I started my app with

rails new test_app --skip-activerecord

Then I went on to remove the gems associated with databases by commenting out the line

gem 'sqlite3'

After a bundle install, no errors appeared, so I thought everything was fine.

The problem started when I tried to generate a new controller.

When I type rails generate controller my_controller I get this big stack trace

/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:50:in `establish_connection'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activerecord-4.2.0/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activerecord-4.2.0/lib/active_record/base.rb:316:in `<module:ActiveRecord>'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activerecord-4.2.0/lib/active_record/base.rb:26:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application.rb:319:in `active_record_configured?'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application.rb:251:in `disconnect_database'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application.rb:97:in `preload'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
        from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from -e:1:in `<main>'

essentially it seems to be telling me that I need my sqlite3 gem back, but wait: didn't I specify I don't want Active Record in my project? Why is it complaining?

I later discovered that removing the sqlite3 gem also prevents me from doing other stuff, such as running rails g -h (which leads to the same stack trace). That hints me the problem is not necessarily related to ActiveRecord, but with some config file requiring sqlite3, but where is it?

Thanks in advance for the help.

gaudi_br
  • 183
  • 2
  • 12
  • Have you looked at your config folder? – vgoff Jul 09 '15 at 05:57
  • I guess you should comment out the code in `database.yml` too. – Pavan Jul 09 '15 at 05:57
  • http://stackoverflow.com/a/19078854/485864 is another possible duplicate. Concerning Rails 4 no active record and no database. – vgoff Jul 09 '15 at 06:00
  • @ Pavan, I haven commented all the lines in database.yml, but that results in another error: `code` in `resolve_symbol_connection': 'development' database is not configured. Available: [] (ActiveRecord::AdapterNotSpecified)`code` – gaudi_br Jul 09 '15 at 06:06
  • @Ludovic: That's where I got the idea in the first place, but I am not sure what to do since in the validated answer, the lines that he suggests to comment out do not exist... (in environment.rb) – gaudi_br Jul 09 '15 at 06:08
  • @vgoff I had missed this post, but it indeed provides a better explanation on the method. I will try it out. Thanks for pointing it out to me. – gaudi_br Jul 09 '15 at 06:10
  • Thanks for all the comments. The procedure described on vgoff's link worked for me. – gaudi_br Jul 09 '15 at 06:47

0 Answers0