- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用 Capistrano 与 puma 和 ngnix 成功部署了 Rails 应用程序。部署后, Assets 未加载到服务器中。我可以使用以下命令在服务器中进行 Assets 预编译:RAILS_ENV=production bundle exec rake assets: precompile 和 locally both。我能够在公用文件夹中看到预编译的 Assets 。在本地它工作正常。但它没有在服务器中加载 Assets 。我无法修复它。
生产.rb
"Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = true
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# config.serve_static_assets =true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# config.assets.precompile += ['omnisling.scss']
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
#config.active_record.dump_schema_after_migration = false
#
# Created new env variable in server .bashrc file as ENV["EMAIL_HOST"] to hold the domain name
# And Changed below line with new env variable, ref: https://omnisling.atlassian.net/browse/OMNS-54
# Changed By: Aravind Sankar
# Date : 25 June 2018
config.action_mailer.default_url_options = {:host => ENV["EMAIL_HOST"]}
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
# ::GATEWAY = ActiveMerchant::Billing::JetpayGateway.new(
# # :login => 'TESTMCC3016X',
# :login => 'AO03B5GME9ZK',
# version: {subscriber: 'BOZHZU', dll: 'GreenBasket 1.0'}
# )
# paypal_options = {
# login: ENV['PAYPAL_LOGIN'],
# password: ENV['PAYPAL_PASSWORD'],
# signature: ENV['PAYPAL_SECRET']
# }
# ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
# spreedly_options = {
# login: ENV['SPREEDLY_ENV_KEY'],
# password: ENV['SPREEDLY_ACCESS_SECRET'],
# gateway_token: ENV['SPREEDLY_GATEWAY_KEY']
# }
# ::SPREEDLY_GATEWAY = ActiveMerchant::Billing::SpreedlyCoreGateway.new(spreedly_options)
end
# Paperclip::Attachment.default_options.merge!({
# :storage => :s3,
# :bucket => ENV["S3_BUCKET"],
# :path => ':class/:id/:style.:extension',
# :s3_credentials => {
# :access_key_id => ENV["S3_SECRET"],
# :secret_access_key => ENV["S3_ACCESS_KEY"]
# },
# :s3_protocol => :https,
# :s3_headers => { 'Cache-Control' => 'max-age=315576000', 'Expires' => 10.years.from_now.httpdate }
# })
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
},
:url => ':s3_domain_url',
:path => '/:class/:attachment/:id_partition/:style/:filename'
}
# Commented to test AWS SES. Below is for Sendgrid.
# config.action_mailer.smtp_settings = {
# :address => ENV['SMTP_ADDRESS'],
# :port => ENV['SMTP_PORT'],
# :user_name => ENV['SMTP_USERNAME'],
# :password => ENV['SMTP_PASSWORD'],
# :authentication => 'plain',
# :enable_starttls_auto => true
# }
# For AWS SES
config.action_mailer.smtp_settings = {
:address => ENV['SES_SMTP_ADDRESS'],
:port => ENV['SES_SMTP_PORT'],
:user_name => ENV['SES_SMTP_USERNAME'],
:password => ENV['SES_SMTP_PASSWORD'],
:authentication => :login,
:enable_starttls_auto => true
}
Paperclip.options[:command_path] = "/usr/bin/"
# Rails.application.config.middleware.use ExceptionNotification::Rack,
# :email => {
# :email_prefix => ENV["ERROR_PREFIX"],
# :sender_address => ENV["ERROR_SENDERS"],
# :exception_recipients => ENV["RECEIVERS"].split(", ")
# }
#
# Created new env variable in server .bashrc file as ENV["EMAIL_HOST"] to hold the domain name
# And Changed below line with new env variable, ref: https://omnisling.atlassian.net/browse/OMNS-54
# Changed By: Aravind Sankar
# Date : 25 June 2018
#
#config.action_controller.asset_host = ENV["HOST"]
config.action_mailer.asset_host = ENV["EMAIL_HOST"]
end"
ngnix.conf
" # For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
#include /usr/local/nginx/conf/mime.types;
events {
worker_connections 1024;
}
http {
client_max_body_size 80M;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
gzip on;
gzip_disable "msie6";
include /etc/nginx/passenger.conf;
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
# root /home/deploy/omnisling/public;
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}"
var/log/nginx/error.log
"2018/12/06 01:16:16 [error] 28064#0: *4 open() "/home/deploy/omnisling/develop/public/assets/os/pos-054e3367b9d18905b322b96613e13dd71c0721a5a1d647b5e8518909c38c288b.jpg" failed (2: No such file or directory), client: 106.51.74.45, server: localhost, request: "GET /assets/os/pos-054e3367b9d18905b322b96613e13dd71c0721a5a1d647b5e8518909c38c288b.jpg HTTP/1.1", host: "52.86.42.50", referrer: "http://52.86.42.50/"
2018/12/06 01:16:16 [error] 28064#0: *1 open() "/home/deploy/omnisling/develop/public/assets/os/ecommerce-ef0801aee6a3ded0a641d7626c7e34a51492f35e3b3e40c42b480f57c8e58917.jpg" failed (2: No such file or directory), client: 106.51.74.45, server: localhost, request: "GET /assets/os/ecommerce-ef0801aee6a3ded0a641d7626c7e34a51492f35e3b3e40c42b480f57c8e58917.jpg HTTP/1.1", host: "52.86.42.50", referrer: "http://52.86.42.50/"
2018/12/06 01:16:16 [error] 28064#0: *5 open() "/home/deploy/omnisling/develop/public/assets/os/mobile_apps-9ec5e2983b86b63469a8b5e41ba287dac94b62e615098973417c24eb34783bfe.jpg" failed (2: No such file or directory), client: 106.51.74.45, server: localhost, request: "GET /assets/os/mobile_apps-9ec5e2983b86b63469a8b5e41ba287dac94b62e615098973417c24eb34783bfe.jpg HTTP/1.1", host: "52.86.42.50", referrer: "http://52.86.42.50/"
2018/12/06 01:16:16 [error] 28064#0: *3 open() "/home/deploy/omnisling/develop/public/assets/os/cart-icon-7b627cb7122f2bdb354ff0caf1d4fe060a2bb26f6e35f73fd945d71d1115201e.jpg" failed (2: No such file or directory), client: 106.51.74.45, server: localhost, request: "GET /assets/os/cart-icon-7b627cb7122f2bdb354ff0caf1d4fe060a2bb26f6e35f73fd945d71d1115201e.jpg HTTP/1.1", host: "52.86.42.50", referrer: "http://52.86.42.50/"
2018/12/06 01:16:16 [error] 28064#0: *6 open() "/home/deploy/omnisling/develop/public/assets/os/pos_icon-7669c3f57465dbe3533a2ff738a867a04e31bf57aa0500d37897025921043c7b.jpg" failed (2: No such file or directory), client: 106.51.74.45, server: localhost, request: "GET /assets/os/pos_icon-7669c3f57465dbe3533a2ff738a867a04e31bf57aa0500d37897025921043c7b.jpg HTTP/1.1", host: "52.86.42.50", referrer: "http://52.86.42.50/"
2018/12/06 01:16:16 [error] 28064#0: *7 open() "/home/deploy/omnisling/develop/public/assets/os/mobile_apps_icon-c763792f0bcdf4d9332a1f72d163d7851df70dfcb8ba868e614773b3c30a2978.jpg" failed (2: No such file or directory), client: 106.51.74.45, server: localhost, request: "GET /assets/os/mobile_apps_icon-c763792f0bcdf4d9332a1f72d163d7851df70dfcb8ba868e614773b3c30a2978.jpg HTTP/1.1", host: "52.86.42.50", referrer: "http://52.86.42.50/"
"
最佳答案
分享您在生产公共(public) Assets 文件夹中的内容。查找 sprockets list 文件。寻找预编译的 Assets 以确保编译按编程进行。
像这样的.sprockets-manifest-ffff2c8e85485d1908eaad36e244e93d.json
关于ruby-on-rails - Assets 在服务器中预编译但未在 puma 和 nginx 服务器中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53647385/
sanitize 是什么意思在 Rails 中是什么意思? 我正在阅读 CanCanCan 的文档.它说: When using strong_parameters or Rails 4+, you
在过去的几个月里,我感觉自己对 Ruby on Rails (RoR) 开发的了解达到了极限。我为大/小客户和 friend /爱好项目开发了大大小小的应用程序。我知道如何开发这些应用程序,但开始感觉
我昨天参加了一个关于扩展 Rails 的聚会,其中一个主题是 Hexagonal Rails。然而,我只做了一年的 Rails,对 MVC 结构非常满意(也许太舒服了),所以我不太了解适配器和消息队列
我使用多个 Rails 应用程序,一些在 Rails 3.2/Ruby 2.0 上,一些在 Rails 2.3/Ruby 1.8.7 上。 他们的共同点是,随着他们的成长和添加更多的依赖项/ gem
这个问题在这里已经有了答案: Using Rails-UJS in JS modules (Rails 6 with webpacker) (5 个答案) 关闭 3 年前。 我正在尝试使用 UJS
我正在开发一个当前使用 Rails 1.2 的 Rails 应用程序,所以我现在离最新的稳定版本(Rails 2.3)还有很长的路要走。 我应该如何进行迁移到更新版本的 Rails 的过程? 我应该一
尝试按照 Ryan Bates Backbone.js 教程构建抽奖应用程序,但我已经遇到了第一段代码的问题。在 application.js 的 init 函数中,他初始化了 Raffler 路由的
我正在使用 Rails 3.2 并且我有一个数据库表,我想在其中找到符合以下条件的所有行: a = true and b = true and ( 0 true, :b =>
我有一个用户类和一个联系人,其中联系人是用户的子类。这两个类都存储在用户表中。 我的联系人可能有也可能没有电子邮件地址,而我的用户需要一个电子邮件地址(我的用户模型定义中有 validates_pre
我正在编写一个教程,我在其中演示了一些 rails 命令。在我的机器上 rails和 script/rails两者都同样有效。有“首选”形式吗?两者中哪一个更普遍? 最佳答案 当您运行 rails 时
我正在寻找有关通过我的应用程序前进的最佳方式的建议,这是我首次开始集成Elasticsearch。我是一名初学者,但是热衷于深入研究,以便原谅任何明显的错误! 我遵循了http://www.sitep
我刚刚用 Rails new 启动了一个新的 Rails 应用程序,将默认数据库设置更改为 PostgresSQL。我用 bin/rails s 启动服务器,结果很奇怪 2016-04-21 05:0
我收到一个参数并希望它是这样的字符串: "abc,efg" 或者像这样的数组 ["abc","efg"] 在第一种情况下,我想将它转换成一个数组,什么是好的方法? 这是我的想法 if params[:
我刚刚用 Rails new 启动了一个新的 Rails 应用程序,将默认数据库设置更改为 PostgresSQL。我用 bin/rails s 启动服务器,结果很奇怪 2016-04-21 05:0
我收到一个参数并希望它是这样的字符串: "abc,efg" 或者像这样的数组 ["abc","efg"] 在第一种情况下,我想将它转换成一个数组,什么是好的方法? 这是我的想法 if params[:
我有 Rails 4,这是我的默认版本(我仍然希望它是)。但我不想在我的电脑上添加 rails 3.2。在以下命令中:gem install rails -v 3.2.16 我有这个警告: railt
您好,我想使用 Sheevaplug 构建一个“Rails Brick”来自 Marvell(操作系统是开箱即用的 Ubuntu,但您可以在其上安装其他发行版)。它将成为家庭服务器和静音、低成本(99
我需要能够从 Rails 控制台发送我的 Rails 应用程序的 Postgres 数据库中所有未接受的邀请。 (我有一个名为 Invitations 的表,其中包含一个名为 accepted 的 b
validate :cannot_modify_if_locked, on: :update def cannot_modify_if_locked if self.locked erro
我正在学习教程(学习 Rails 播客),需要更改以下路由语法,以便它与 Rails 3.0 兼容。谁能帮忙? map.view_page ':name', :controller => 'viewe
我是一名优秀的程序员,十分优秀!