繁体   English   中英

部署到服务器后访问Rails控制台

[英]accessing Rails Console after deploy to server

我在生产中无法访问rails控制台。

我使用Capistrano将应用程序部署到VPS

如果我cd deploy@myapp:~/myapp/current$并运行bundle exec rails c那里我总是得到用于创建新rails项目的选项列表,比如rails new

我也尝试过bundle exec rails console --productionrails console等所有结果相同。

问题是我必须能够访问控制台,因为我必须为active admin创建管理员用户

可能值得补充一点,我在Ubuntu 16上使用Passenger / Capistrano和Nginx

有谁知道这里发生了什么? 难道我做错了什么?

*编辑

运行RAILS_ENV=production bundle exec rails c我收到此消息

 Looks like your app's ./bin/rails is a stub that was generated by Bundler.

 In Rails 4, your app's bin/ directory contains executables that are  versioned
 like any other source code, rather than stubs that are generated on demand.

  Here's how to upgrade:

  bundle config --delete bin    # Turn off Bundler's stub generator
   rake rails:update:bin         # Use the new Rails 4 executables
  git add bin                   # Add bin/ to source control

   You may need to remove bin/ from your .gitignore as well.

  When you install a gem whose executable you want to use in your app,
  generate it and add it to source control:

  bundle binstubs some-gem-name
  git add bin/new-executable

  Loading production environment (Rails 4.2.5)
  irb(main):001:0> 

在Capistrano部署后,您缺少生产bin文件夹的可执行文件。

您需要从Capistrano deploy.rb中的set :linked_dirs删除bin ,以避免对其进行符号链接。

您可以再次尝试cap production deploy ,它会将所有可执行文件从bin转移到Production。

现在,您可以使用以下命令访问rails控制台:

RAILS_ENV=production bundle exec rails c

如果您使用的是Capistrano 3,则可以包含rails:console选项,该选项允许您从本地计算机执行此操作以访问远程主机上的控制台:

bundle exec cap production rails:console

https://rubygems.org/gems/capistrano-rails-console

检查rvm和gemset是否适合该应用程序

rvm gemset list 
rvm list

然后呢

bin/rails rails c -e production

默认情况下,Rails项目部署在服务器上的/deploy/your_project_name/current 因此,您可以通过SSH或...访问它,并运行bundle exec rails c来访问Rails控制台。 这个对我有用!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM