在这个问答内容中,我们要讨论的是如何在Rails应用程序中部署到子目录中。Rails是一个基于Ruby语言的Web开发框架,它提供了一种简单、灵活的方式来构建Web应用程序。
在Rails应用程序中部署到子目录中,可以通过以下步骤来实现:
config/environments/production.rb
文件,添加以下代码:config.relative_url_root = "/子目录名称"
将子目录名称
替换为实际的子目录名称。
config/routes.rb
文件,添加以下代码:Rails.application.routes.draw do
mount_at = Rails.application.config.relative_url_root.present? ? Rails.application.config.relative_url_root : "/"
mount ActionCable.server => "#{mount_at}cable"
end
config/initializers/assets.rb
文件,添加以下代码:Rails.application.config.asset_host = Proc.new { |source, request|
if request.path.starts_with?(Rails.application.config.relative_url_root)
"#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
else
"#{request.protocol}#{request.host}:#{request.port}"
end
}
config/initializers/session_store.rb
文件,添加以下代码:Rails.application.config.session_store :cookie_store, key: "_#{Rails.application.config.relative_url_root.gsub(/[^a-zA-Z0-9]/, '')}_session"
config/puma.rb
文件,添加以下代码:if Rails.application.config.relative_url_root.present?
app_path = Rails.application.config.relative_url_root
else
app_path = "/"
end
config/environments/production.rb
文件,添加以下代码:config.action_controller.asset_host = Proc.new { |source, request|
if request.path.starts_with?(Rails.application.config.relative_url_root)
"#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
else
"#{request.protocol}#{request.host}:#{request.port}"
end
}
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = Proc.new { |source, request|
if request.path.starts_with?(Rails.application.config.relative_url_root)
"#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
else
"#{request.protocol}#{request.host}:#{request.port}"
end
}
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}"
config/environments/production.rb
文件,添加以下代码:config.action_mailer.default_url_options = { host: "#{request.host}:#{request.port}#{Rails.application.config.relative_url_root}" }
config/environments/production.rb
文件,添加以下代码:
config.action_mailer.asset_host = "#{request.protocol}#{request.host}:#{request
算法大赛
云+社区技术沙龙[第17期]
Elastic 实战工作坊
Elastic 实战工作坊
腾讯云数据湖专题直播
企业创新在线学堂
云+社区沙龙online [技术应变力]
领取专属 10元无门槛券
手把手带您无忧上云