Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running Rails console in production

I have just gone live with my first Rails site, but now I have a problem. When I run the project in development mode on my IDE I can run the console to something like:

User.first.name='whatever' to change a users name.

How do I accomplish the same task on a live site in production mode?

like image 961
nFinIt_loop Avatar asked Feb 28 '13 18:02

nFinIt_loop


People also ask

How do I run rails console on server?

Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .

What is the rails console?

Rails console is a command line program for interacting with the Rails applications. It has the full power of the Ruby language and Rails environment.


1 Answers

if you're running rails 3.0 or greater, you can also use

rails console production 

production can of course be substituted with development or test (value is development by default)

Adding the option --sandbox makes it so that any changes you make to your database in the console will be rolled back after you exit

If this isn't working for you, you may need to try

bundle exec rails console production 

If you are actually trying to run the rails console on your production server, try googling "run rails console [your cloud hosting provider]" e.g. "run rails console heroku"

As of Rails 6 you need to use

RAILS_ENV=production bundle exec rails c 

or

RAILS_ENV=production rails c 

depending on your setup

like image 78
Peter Berg Avatar answered Sep 16 '22 21:09

Peter Berg