Can't connect dumped MongoDB with Rails 3.1 and Mongoid - ruby-on-rails

A Rails 3.1 app is running locally fine with MongoDB and mongoid (until I don't modify anything).
I need the production DB so I dumped it properly. Now I need to configure the Rails app to connect or use this new dumped database.
I copied all the Mongodb's BSON files into the folder where my local Mongo (which started by 'mongod' command) looking for (/data). All files in one folder (/data/e).
How to configure MongoDB or Rails or mongoid.yml to use specifically that folder which I moved there?
+++
Additional info:
Made mongodump successfully. Now I need to import it to the testserver, probably with mongoimport. How to do that?

You don't do that. To dump/restore a MongoDB database, you should use the mongodump and mongorestore utilities

Related

Ruby On Rails - "OpenSSL::Cipher::CipherError at ..." when connecting to imported database

I am running my Ruby On Rails 5 app on localhost and now, I imported the production database. It's a PostgreSQL database, exported via the pg_dump tool.
When I modified the database.yml file the Rails app and set there the newly created database, I got this error when running the Rails app (tried also to change the port on which the app is running, but it didn't help):
OpenSSL::Cipher::CipherError at /
In the Rails console is not any information about the error.
What is the reason of such an error? I tried to export the database from the staging server and use it on localhost and everything worked fine.
Based on the docs: https://ruby-doc.org/stdlib-2.4.1/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-i-final
It looks like you don't have the proper encryption key to connect to the production db.
I would guess you either do have the proper one for staging, or staging is running unencrypted.
Here's someone else with the same error caused by an incorrect key: OpenSSL::Cipher::CipherError when running staging DB on local

Rails server not working when copying back from staging deploy

I ssh copied a rails app from a staging server because the development repository has been lost. My goal is to create a new development code base using the deployed code as a source. So far I have removed a hidden .bundle folder and replaces several aliases with folders and files. I then ran bundle install. For the database I did a sql dump from staging and used it to build a development database. I think I'm ready to run rails server. But when I try to run rails server in the base directory. It gives me the rails command line help as if I was running rails s in a directory with no app.
I'm not even sure if it is possible to reverse a deploy this way. I've looked at the rails guide on the app initialization process and all the files seem to be in place.
Remember that for Rails to start up, you need bin/rails, bin/bundle, config/boot, etc.
If you restore those files, it should work again.

synching two databases in heroku rails app

I have crm rails application deployed in heroku so my database is postgresql. I have an iphone app which is using mysql database. Now what i need to do is to synch my iphone database with my heroku database.
Can anyone please help me on this is it possible to sync two different databases in heroku
Thanks in Advance
The way we did this was to do it manually
Yep, it's a real pain, but at least you know it's done correctly
--
Process
For migrating from Postgres to MYSQL is as follows:
"Backup" the database using pg_backups
Download the backup locally
In MYSQL (we used PHPMyAdmin), create a series of SQL calls to insert the respective data into the correct tables
Migrating from MYSQL to Postgres is, as much as I can determine, a similar process:
Download the SQL dumps of your MYSQL DB (I only know how to do this in PHPMyAdmin)
Configure those files to be "PG" ready
Send the SQL to your Heroku postgres db's
--
Notes
For specifics, I only have the following:
If you dump from Heroku, you'll not get a traditional SQL file; you'll receive a .dump file. To change this, you'll need to use pg_restore in the following way:
$ cd c:/your/postgres/install/pg_restore/location
$ pg_restore path_to_your_dump.dump > path_to_your_sql.sql
This will give you the ability to "read" the file, uploading to your db & importing as you wish. That's when the fun begins :)
Importing MYSQL
The way to import MYSQL into a PG db will have to be done manually
Although we've never done this directly (we only migrated from PG), there are several things you can do. Firstly, you can use the PG2MYSQL converter to give you an idea as to the syntax differences between MYSQL & PG
Then I would perform a "dump" from MYSQL in SQL format. This will give me the data required for PG. This will allow me to insert into my PG database (you might have to do this locally to give you the ability to determine the syntax), from which you can then patch in the MYSQL data
I understand it's not the most elaborate explanation - I hope it gives you some ideas

Database in Rails application

I cannot find where the database in my Rails application is located. I looked in folders like /db, /db/migrate, and /app/models, but cannot find the actual database that I can open to examine the data. Where is it located?
Try running rails dbconsole from the command line while you're inside your project directory.
If you're running a SQLite Db (which rails runs by default), you can download SQLite DB Browser (http://sqlitebrowser.sourceforge.net/), and open your db/sqlite3 file to view the actual data, or if you're using mysql, check out: http://www.sequelpro.com/

Disable MongoDB from rails 3.0.9 application start up?

My project uses both MySQL(for ActiveAdmin tables) and MongoDB(for rake task that does logs file parsing) as database. I have used Mongoid to connect my app to MongoDB. So I just have mongoid.yml file extra in /config directory along with other usual files(No other files to setup MongoDB connection). However whenever I try to run migrations for MySQL or start my app it requires MongoDB running in the background else the server/task wont start and gives an error
Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
Keeping MongoDB continuously running is not required. Please guide me in excluding this compulsion.
There seems to be some discussion on this topic here: https://github.com/mongoid/mongoid/issues/1166
Perhaps you could wrap the connection so that it checks for a certain flag or environment variable which you would use for mysql only mode.

Resources