如何在 Amazon ec2 上运行 seed.rb 文件 [英] How to run seed.rb file on Amazon ec2

本文介绍了如何在 Amazon ec2 上运行 seed.rb 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我使用 Elastic Beanstalk 在 Amazon EC2 上托管了我的 Ruby on Rails 应用程序.除了我的seeds.rb 文件外,一切正常.我的seeds.rb 文件在托管时未执行.我也在使用 ActiveAdmin 并且我在我的 seed.rb 文件上定义了第一个管理员.

Recently I hosted my Ruby on Rails application on Amazon EC2 using Elastic Beanstalk. Everything works fine except my seeds.rb file. My seeds.rb file is not executed at the time of hosting. I am using ActiveAdmin also and I define first admin on my seeds.rb file.

如何通过 rails 控制台在 Amazon 上创建第一个管理员用户?有什么办法可以在 Amazon EC2 上打开 Rails 控制台? 我正在尝试使用腻子来执行此操作,但不知道如何执行此操作.请给我一些指点..

How can I create first admin user on Amazon by rails console? Is there any way to open Rails Console on Amazon EC2 ? I am trying to do this using putty but don't know how to do this. Please give me some pointers..

推荐答案

您需要创建密钥对才能访问 amazon 实例(我认为您已经拥有了).确保在当前选择的安全组中启用了 ssh 访问.

You need to create keypair to access the amazon instance(which i think you already have). Make sure that ssh access is enabled in the current selected security group.

您可以使用

ssh -i path/to/keypair.pub ec2-user@ec2-an-ip-address.compute-1.amazonaws.com

然后 cd 进入应用程序目录并运行 bundle exec rake db:seed RAILS_ENV='staging' 假设您在 staging 环境中运行应用程序.

Then cd into the app directory and run bundle exec rake db:seed RAILS_ENV='staging' assuming that you're running the app in staging environment.

这篇关于如何在 Amazon ec2 上运行 seed.rb 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆