DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Hasan N.
Hasan N.

Posted on

Running Rails Console Commands on Terminal

Wherever you are unable to run the rails console directly we can use something else. I found that to be helpful since I didn't have admin rights on the EC2 terminal but I had to play with rails console for Staging Environment

bundle exec rails runner "_rails command_" -e $(ENVIRONMENT)

is that helpful command which helped me in running rails commands for the staging environment. We should definitely avoid using it as much as possible but there are scenarios where playing with rails console is our only choice.

Example commands:

bundle exec rails runner "puts Cart.where(tenant_id: 3).destroy_all" -e staging

Top comments (0)

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.