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

Dau*_*ell 3 ruby capistrano ruby-on-rails rails-console

我在生产中无法访问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> 
Run Code Online (Sandbox Code Playgroud)

dp7*_*dp7 7

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

您需要删除binset :linked_dirs您的Capistrano的deploy.rb,以避免符号链接它.

您可以再次尝试cap production deploy,它将所有可执行文件从bin生产.

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

RAILS_ENV=production bundle exec rails c
Run Code Online (Sandbox Code Playgroud)