sqlite3 won't go away....ruby on rails - ruby-on-rails

I am trying to get rid of sqlite3 on my rails app and use postgres instead. I updated my gem file and removed it. manually uninstalled the sqlite3 gem. Got rid of it in my database.yml file. When I run rake db:create (As instructed on heroku) I get this:
db/development.sqlite3 already exists
I tried a whole bunch of rake commands and it continually refers to sqlite3. Why? I removed it? How do I remove it permanently from my app so I can go ahead and use postgres to deploy to heroku?
thank you so much itches head in mild frustration

This might be a sticky setting because spring is running. Did you try stopping spring?
spring stop

Related

warning: circular argument reference - now rake aborted! on rake db:migrate

On rake db:migrate, I am getting following error.
ruby-2.2.1/gems/activesupport-4.0.2/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
My rails gem gem 'rails', '4.0.2'
What's the solution for this?
From your error, it sounds like you are trying to use a Postgres database with your rails project. Basically, postgres runs separately from your rails project. You need to make sure you have:
a) installed postgres using something like homebrew
b) found a convenient way to start your postgres server when you need to (I recommend the one on postgresapp.com)
c) actually started the server before running the command that's producing this error (e.g., through opening the postgresapp or in a separate terminal window)
Conceptually, think of it this way: you can't migrate (e.g. 'change') a database that's inaccessible because the postgres server is down. That's what the error means.
As an alternative, you can use SQLite instead of Postgres. SQLite does NOT run as a separate process (https://www.sqlite.org/serverless.html), so you will run into these problems less. However, in your ruby code, you will need to pay attention to exactly how to configure your app for a postgres database or a sqlite database, whichever you choose. Here is a great SQLite tutorial for initial set-up:
http://www.integralist.co.uk/posts/active-record.html

Can't Rake Database "Undefined method "each" For SQLite"

Hello I am just getting started putting up a test database. I am using the preloaded rails environment from digital-ocean if that helps anything.
So I have just cloned my application from github and went rake db:create. When I did that it says there is an undefined method each for SQLite. I am not using sqlite though? I have specified PostgreSQL as the adapter.
I am a noob so sorry If this is a dumb question. Thank you in advance.
Use:
rake db:create
Not
rake:db create
I removed SQLite using gem uninstall sqlite3 then restarted the server. Everything started to work after that.

I cannot deploy my newly created app on heroku because of postgresql

I'm learning Ruby on Rails, and having lots of difficulty setting up.
So I have created this new app, using 'rails new' command.
Modified a bit, and now on way to deploy it on heroku.
First try, it failed because heroku required the app to use postgresql rather than sqlite3, which was set as a default database.
So I downloaded and installed postgresql, and here is the where the trouble began.
After installing the postgres, I set up the path.
And then I was unable to run the app locally anymore.
In command, "rails server" command is not working anymore, showing all kinds of error not being able to load stuff.
It looks like this:
D:\ruby\appname>rails server
c:\RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/pg-0.17.1-x86-mingw32/lib/pg.rb:10:in 'require': cannot load such file --2.1/pg_ext <LoadError>
and another bunch of load error.
No need to mention deploying on heroku, it fails everytime.
After installing postgresql, I can't use any database related commands as it says "loaderror" everywhere.
I can't run the app locally, nor deploy on heroku.
How should I fix this database problem?
In development you can still use SQLite, and in production use Postgres.
It's not advisable forever to have that disparity, but it does mean you an make progress.
Remove any production settings in database.yml, but still include 'pg' in your Gemfile.
Heroku will automatically insert database settings for Postgres in production. Deploy and then run heroku run rake db:migrate to set up your database.

How to switch my Rails app to postgresql from Sqlite3?

So I started working on a Rails app recently and we decided (well not me, the person working on it with me) that we should switch from Sqlite3 to Postgresql. I've installed Postgresql on our server properly, created the databases for dev, prod, and test, and updated my Gemfile and database.yml files with the code for Postgres. The thing I'm unsure of now, is how to switch out all the files in the db directory with the Postgres databases. Do I just delete the contents of the db directory in my app and run rake db:create?
You'll want to edit config/database.yml to use postgresql instead of sqlite.
The migrations in db/migrate/*.rb are hopefully cross-database compatible, and wont need to be changed.
Running rake db:create db:migrate with the new database.yml should create the PostgreSQL database and you'll be up and running.
In reality, you'll probably run into various problems, but this will be a starting point.

Heroku App is Reading database.yml File

From what I can gather, Heroku is supposed to generate a database.yml file automatically, and ignore the local one. However, I am seeing an error where that is not true, and my changes to the local database.yml are affecting the Heroku app. This is problematic because I have no idea how I should setup production portion of the file so Heroku can find the right database.
For instance with the following
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
followed by the db:migration
$:~/Apps/DancingCupid/DancingCupid$ heroku rake --trace db:migrate
spits out
rake aborted!
unable to open database file
/app/.bundle/gems/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `initialize'
...
I can get different errors depending on what type of database I sent for production.
Besides deleting the app and making a new one, is there a way to fix this problem?
Heroku definitely rewrite your database.yml on push so it doesn't matter what is in there in source control.
To confirm this do heroku run bash which will connect you to a bash session in your app then look do a cat config\database.yml and you will see how they have rewritten it.
The other answers are NOT TRUE anymore as of Rails 4.1.
config/database.yml won’t be overwritten anymore when a Rails 4.1.0
RC1 app is detected. Instead, it will be merged with DATABASE_URL so
additional options like pool size can be set in config/database.yml.
To double-check the contents of your database.yml on the Heroku server, you can run remote bash via heroku run bash and then cat config/database.yml to see its contents on the server and compare with your local one.
I don't think you are insane! ( But I thought I was )
I have been beating my way around this problem for a few days, and finally found this article:
http://article.gmane.org/gmane.comp.lang.ruby.rails.heroku/1003/match=database+yml
It led me to believe that maybe it wasn't my code at all!
I then simply destroyed my heroku app and created a new one, and pushed to it. Suddenly everything works fine! I don't know how or when or why, but I think it is possible to overwrite or corrupt the database.yml file that Heroku creates.
Hope this helps!
Try removing database.yml from version control. It's good practice to make a copy of database.yml into something like database.yml.example and adding database.yml to your .gitignore file.
That way when you push to Heroku it won't have any database configuration to refer to.
You probably also don't want the sqlite3 gem in production. Make sure it's in the development/test groups in your Gemfile.
database.yml should not be pushed to Heroku. It will try to connect to that database, timeout and then crash.
Add it to your .gitignore so it doesn't get up there.

Resources