Jessicascn
Jessicascn

Reputation: 161

Access rails console from AWS elastic beanstalk

I have a ROR app but it's the first time I am using AWS, usually I use heroku.

Is there any way to run the equivalent of heroku run rails c?

I want to access my rails console to update some stuff in my database.

I've checked online and tried

  cd /var/app current   

It tells me that there is no such file or directory. I've also tried

  sudo su
  bundle exec rails c production

It is not loading the console but only shows me sh-3.2 at the start of the console line.

I've also tried eb ssh but it does not recognize eb.

Could someone explain to me how I can access the rails console and why I have to run the given commands. I don't understand.

Thanks a lot!

Upvotes: 1

Views: 1174

Answers (2)

Kome
Kome

Reputation: 56

That's because the path is invalid.

cd /var/app current -> cd /var/app/current

And even so, it's complicated to get environment variables and start rails console on production in elastic beanstalk. See https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/custom-platforms-scripts.html#custom-platforms-scripts.get-config

Upvotes: 0

sameera207
sameera207

Reputation: 16629

first, you need to ssh into the EB instance. (assuming you have EB installed and ssh setup),

  • eb ssh #-> this will list your EB instances Once in the instance, do

  • cd /var/app current #-> this command will take you to the current rails source code.

  • sudo su #-> switch user
  • bundle exec rails c production #-> runs the rails console (like in local machine)

Upvotes: 2

Related Questions