Four questions about Rails (console, seed file, environment variables, precompiling assets)

  • Posted June 14, 2013

I used to deploy to Heroku but recently joined DO. I got up and running here with the help of Ryan Bates Railscast on deploying to a VPS, but there are some things he doesn’t cover.

  1. Can I run the rails console on my ubuntu server?

I ran “rails console” in the directory of my app and it gave me a menu of options, such as ‘rails new’ but there was no option to run the rails console

  1. I want to seed my app with some starter data. I can’t run ‘rake db:seed’ (as I would on Heroku) from my app directory. It says no rake file.

3.Environment variables. I need to set Environment Variables for various services that require them (such as email services like Mandrill). How do I set them on DO

  1. On Heroku, I used to have to do rake assets:precompile for a Rails app to deploy. This wasn’t a requirement on DO. Why (out of curiosity)?

(See full trace by running task with --trace)


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Assuming you’re on Rails 4, have you tried:

# Feel free to add this line to e.g. ~/.bashrc so you don't have to type it all the time.
export RAILS_ENV=production

bin/rails console
bin/rake db:version

and so on?

The rails in your path may be different from the one used by your app; bin/rails should get you the right one.

Had the same problems. <br>It seems like unicorn is by default starting in development environment. <br>Just add -E production in the line UNICORN_OPTS=… in file : /etc/default/unicorn <br>So that it looks like : UNICORN_OPTS=“-D -c $CONFIG_RB -E production” <br>then : RAILS_ENV=production bundle exec rake assets:precompile <br>restart unicorn and it should work.

@m73mitchell did you ding any solution to this? <br> <br>I am facing the “database configuration does not specify adapter” error. <br> <br>

To run rake and rails console I had to specify production environment like this. For example, <br> <br> RAILS_ENV=production rake db:seed <br> <br>For environment variables, in bashrc <br> <br>export LD_ASSUME_KERNEL=2.2.5 <br>

Actually once I cd into the correct folder and run ‘rails console’ or ‘rake db:seed’ I’m getting this error <br> <br> configuration does not specify adapter (ActiveRecord::AdapterNotSpecified) <br> <br>even though the application is actually otherwise working (and saving records). <br> <br>This is the full database.yml file <br> <br>production: <br> adapter: postgresql <br> encoding: unicode <br> database: dodeploy_production <br> pool: 5 <br> host: localhost <br> username: michael <br> password: secretpassword

Sorry, to provide more information, the directory structure is the following <br> <br>home/username/apps/nameofapp/ <br> <br>Inside ‘nameofapp’ there’s three folders ‘current’ ‘releases’ and ‘shared’. I think these were created by the deploy file that I borrowed from RBates. <br> <br>When I’m inside current and run “rails console” and “rake db:seed” (there is a rake file), I’m getting the same error <br> <br> <br>‘database configuration does not specify adapter’ <br> <br>However, inside my database yml file I have this <br> <br> <br>production: <br> adapter: postgresql <br> encoding: unicode <br> database: dodeploy_production <br> pool: 5

in home/username I created a new directory ‘app’ where the rails app is stored (and where I might store others), so now I have home/username/app. How do I set them in that /etc/profile file? <br> <br>Would I for example just do this at the bottom of the file? <br> <br>GMAIL_USERNAME=‘’ <br> <br> <br>Do you have any idea about the other questions, how to seed data or run the rails console? running the console on a remote server is very handy, as it lets you alter and view production data etc

when you say you’re in your “app” directory what does it look like, what subfolders, to make sure it’s the right directory… <br>if you want to set environment variables I’d probably set them globally, like in /etc/profile file. HTH.