我使用 Capistrano 来部署带有 Ruby 3.1.1 的 Rails 7.0.2 应用程序,当我运行时cap production deploy ,然后当 Capistrano 运行时:
deploy:assets:precompile
$HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`
Run Code Online (Sandbox Code Playgroud)
部署.rb:
# config valid for current version and patch releases of Capistrano
lock '~> 3.17.0'
set :application, 'app'
set :repo_url, 'git@github.com:foo/app.git'
# Deploy to the user's home directory
set :deploy_to, "/#{fetch :application}"
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'
# Only keep …Run Code Online (Sandbox Code Playgroud) 我正在使用 Ruby 3.0.2 开发 Rails 7.0.2 应用程序,并且正在按照刺激教程制作剪贴板复制按钮https://stimulus.hotwired.dev/handbook/hello-stimulus。当我按下按钮什么也没有发生,我已经覆盖了我的控制器连接方法以在连接时登录到控制台,但没有记录任何内容。我还在浏览器开发工具中收到一些奇怪的消息:
\nUncaught TypeError: Error resolving module specifier \xe2\x80\x9capplication\xe2\x80\x9d. Relative module specifiers must start with \xe2\x80\x9c./\xe2\x80\x9d, \xe2\x80\x9c../\xe2\x80\x9d or \xe2\x80\x9c/\xe2\x80\x9d. data:28:7\nUncaught Error: Unable to resolve specifier \'@rails/request.js\' imported from http://localhost:3000/assets/application-234f8bed8636066fccb3be9d9c37552702ed61ecdcfeb919a52fa12d5a694d68.js\nRun Code Online (Sandbox Code Playgroud)\n我的控制器:
\nimport { Controller } from "@hotwired/stimulus"\n\n// Connects to data-controller="copy"\nexport default class extends Controller {\n static targets = ["source"]\n\n connect() {\n console.log("connect");\n alert("connect")\n }\n\n copy(){\n navigator.clipboard.writeText(this.sourceTarget.value)\n }\n}\nRun Code Online (Sandbox Code Playgroud)\nHTML:
\n <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6" data-controller="copy">\n <dt class="text-sm …Run Code Online (Sandbox Code Playgroud) 您好,我正在尝试运行以下命令来准备我的 Rails 应用程序以进行生产:
bundle lock --add-platform ruby
bundle lock --add-platform x86_64-linux
Run Code Online (Sandbox Code Playgroud)
然后我得到这个错误:
Cannot write a changed lockfile while frozen.
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?锁文件有什么用?被冻结是什么意思?
我正在尝试使用Set标准 Ruby 库中的类。我正在创建一个空Set像这样:
Set.new
Run Code Online (Sandbox Code Playgroud)
但后来我遇到了这个错误:
main.rb:36:in `<main>': uninitialized constant Set (NameError)
Set.new
^^^
Run Code Online (Sandbox Code Playgroud)
如何正确创建一个空实例Set
ruby ×4
capistrano ×1
credentials ×1
javascript ×1
lockfile ×1
oop ×1
rubygems ×1
set ×1
stimulusjs ×1