How to manually manupulate data in the production database?
Hi,
I just successfully deployed my Rails app to a Digital Ocean VPS, following the Deploy Rails guide on this website. Many thanks go to Chris Oliver and James Dullaghan for their help and patience.
Now my app is deployed, I need to create an admin user so I can log in and start to create content.
On heroku I was able manipulate the database through the Rails console, with the command:
heroku run rails console
However, I'm not sure how to manually enter data in the database on my VPS.
Can I also spin a Rails console and access the production database, or do I need to do this another way?
Thanks for your help,
Anthony
found it, because on the vps I don't have a development environment, I need to start the Rails console in the 'current' folder with:
RAILS_ENV=production bundle exec rails c
Glad you found it. Here's a protip. If you ever want to test out different code, queries, or manipulate data without permanently writing to the database use the sandbox option.
RAILS_ENV=production bundle exec rails c --sandbox
This will give you a Rails console where you can test out your code and manipulate data in realtime to see what the effects are. Once you exit the console, all changes are rolledback so it's a really safe way to play with production data before you manipulate anything permanently.
Hi, sorry to bring this topic up again after almost a year. I did as the tutorial showed by Chris to set up a digital ocean vps on Ubunto 14.04 with passenger phusion, nginx and capistrano. However, I am not able to access the the rails console when on my virtual machine. The command above doesn't work for me. It shows..
Usage: rails new APP_PATH [options]
I even tried installing capistrano-rails-console gem but it still show the same error message.
To add, the app works fine after I deployed it last night. It would be great if I could get into console to add some records.
Ok got it to work. Had to remove bin
from set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
.
This is for capistrano 3.
Ah yeah! I've had to remove bin from that as well. Not sure what changed but that definitely fixes the problem.
Thanks Chris! Yea spent a whole day trying to figure it out. Most answers were for capistrano 2. Tried installing capistrano rails console and still nothing. Hope it helps anyone facing the same problem. Maybe I'll post a comment on the deployment guide to share this tip.