Rails - disable db connections - ruby-on-rails

There's a Rails 3.2.3 web application which doesn't use any database. But in spite of that if I use the gem 'sqllite3' in GemFile I works perfect. But if I use gem 'pg' in that file it throws an error
ActiveRecord::ConnectionNotEstablished
Of course, I use different versions of database.yml when I use postgreSql or SqlLite3.
But I definitely don't use any database.
Why is it happening? What should I do to solve it? And how to disable using databases?

See the SO question here for how to bypass using a database. It's a little more work than just setting a flag.

Related

settings say sqlite, connection says postgres

Trying to figure out whats the deal with this.
Im using rails 7.0. Used rails a while back so not really too sure what im doing wrong.
The settings show its all pointing to Sqlite but its trying to connect to postgres.
I havent changed anything, rails new my_app and this is what I got.
I assume that you have the pg gem in your Gemfile and not the sqlite gem. Fix that and it will work.

ActiveRecord::ConnectionNotEstablished: No connection pool for ActiveRecord::Base with mongoid

I have a Rails 4.2.8 app, ruby 2.4.4 with a Mongo database, using the mongoid ODB.
I want to run tests against this application using rspec. The most basic test gives me this error:
ActiveRecord::ConnectionNotEstablished: No connection pool for ActiveRecord::Base
My research on this problem lead me to these conclusions, but I do not know how to solve the problem itself:
why is active record mentionned here, when it is not in my gemfile ? Maybe another gem is loading it at some point, but how can i get rid of this problem ?
my application.yml and mongoid.yml file are correctly configured. I can RAILS_ENV=TEST rails console and I can query documents.
looks like rails is going inside the condition line 15 in this file. So how and why is ActiveRecord loaded at some point ?
Some help would really be appreciated as I do not know what to do next...
Ok so I did not figure out who was loading ActiveRecord in my application, but I manually unload it in my rails_helper.rb:
Object.send(:remove_const, :ActiveRecord)
# Make sure it is above this
require 'rspec/rails'
I ran into the same issue and found that the problem was database cleaner. Previously we were using the gem database_cleaner but that gem seems to have been split based on your database adapter. Switching to database_cleaner-mongoid resolved the issue. Note that you may need to change some requires or config values to get things running correctly after the change. For instance I had an error about my strategy not being supported in mongoid.

switching from sqlite to postgres in rails app I´m working on

I am rather new to rails and I was thinking about how much trouble is it to switch from sqlite to postgres in an app that I´m currently working on. The thing is I have never switched in a middle of the building App process.
My local database has some data, but it is not relevant and may be deleted. I´m more concerned about the tables, columns, models, etc...
My reasons for the switch are:
I want to be able to use the 'groupdate' gem with my 'chartkick' gem in developement.
Later I will deploy to Heroku, I have done that before with adding 'pg' gem to production.
I have Postgres installed on my computer and I also have Postgres.app. I´ve been testing chartkick with groupdate in another project, so Postgres is not the problem.
So the question is basically, how much trouble is to switch from sqlite to PG in a middle of a project and what is the easiest and fastest way to do it?
sorry for the long text, hope someone reads it :)

Ruby on Rails Vacuum Gem

I am new to Ruby on Rails and I am trying to access the Amazon Product API using the Vacuum Gem. Based off this code https://gist.github.com/frankie-loves-jesus/89d24dd88579c7f912f3 I am getting an error at the first line
request = Vacuum.new('GB')
telling me that I have an "Uninitialized constant AmazonAPIController::Vacuum" every example on this gem tells me to use this line of code but I can't understand how to fix the error. It seems to be as simple as putting the code into my controller and showing it.
You didn't add the gem to your Gemfile I guess and didn't run bundle install afterwards. Also you should make sure to restart your Rails server after every change in your Gemfile.
If all that doesn't help, you also could try to just gem install vacuum and then require 'vacuum' in the file you are using (but I would recommend getting it to work on another way).

How to disable sqlite3 while using neoid?

I am using neoid with rails and want to disable sqlite in my rails application. How can I do this (after that I want to use only neoid and neo4j to store the data)?
Remove
gem 'sqlite3'
from your Gemfile and make sure that your config/database.yml file doesn't contain lines like
adapter: sqlite
From my testing with it today I don't think you can do this with this gem. Neoid adds neo4j storage as an addition to, not replacement for, your traditional RDBMS.
To have a full replacement for RDBMS-backed ActiveRecord you may need to consider the neo4j.rb gem, which requires JRuby.

Resources