【问题标题】:Deploying Ruby on Rails app to Heroku: Links not working, Images not appearing将 Ruby on Rails 应用程序部署到 Heroku:链接不起作用,图像未出现
【发布时间】:2017-04-19 12:16:57
【问题描述】:

我刚刚在 Heroku 上部署了我的应用程序,发现我的图像都没有显示,并且即使我的应用程序在本地运行良好,链接也无法正常工作。请点击此链接查看:
https://obscure-depths-71348.herokuapp.com/

您可以看到,每次按下“注册”、登录”或“直播”按钮时,您都会看到, “很抱歉,出了点问题。”

更令人痛苦的是,当我在命令提示符下输入“heroku logs”时,我得到了一个永远长长的致命错误列表:

2016-12-05T06:30:46.235005+00:00 app[web.1]: F,    [2016-12-05T06:30:46.234958 #4] FATAL -- :   

[017e9049-b5c9-4f4c-8b0d-7380e3136888]
供应商/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/tagged_logging.rb:70:in tagged' 2016-12-05T06:30:46.235054+00:00 app[web.1]: F,
[2016-12-05T06:30:46.235006 #4] FATAL -- :
[017e9049-b5c9-4f4c-8b0d-7380e3136888]
vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/rack/logger.rb:24:in
call' 2016-12-05T06:30:46.235418+00:00 heroku[路由器]: at=info method=GET path="/assets/contactcover.jpg"
host=obscure-depths-71348.herokuapp.com
request_id=017e9049-b5c9-4f4c-8b0d-7380e3136888 fwd="153.104.25.21"
dyno=web.1 连接=1ms 服务=13ms 状态=404 字节=1744 2016-12-05T06:30:46.235110+00:00 app[web.1]: F, [2016-12-05T06:30:46.235059 #4] 致命 -- :
[017e9049-b5c9-4f4c-8b0d-7380e3136888]
供应商/bundle/ruby/2.2.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/request_id.rb:24:in call' 2016-12-05T06:30:46.235160+00:00 app[web.1]: F, [2016-12-05T06:30:46.235112 #4] FATAL -- :
[017e9049-b5c9-4f4c-8b0d-7380e3136888]
vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/method_override.rb:22:in
call' 2016-12-05T06:30:46.235276+00:00 app[web.1]: F, [2016-12-05T06:30:46.235209 #4] 致命 -- :
[017e9049-b5c9-4f4c-8b0d-7380e3136888]
供应商/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' 2016-12-05T06:30:46.235207+00:00 app[web.1]: F, [2016-12-05T06:30:46.235161 #4] FATAL -- :
[017e9049-b5c9-4f4c-8b0d-7380e3136888]
vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/runtime.rb:22:in
call' 2016-12-05T06:30:46.235333+00:00 app[web.1]: F, [2016-12-05T06:30:46.235277 #4] 致命 -- :
[017e9049-b5c9-4f4c-8b0d-7380e3136888]
供应商/bundle/ruby/2.2.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/executor.rb:12:in call' [even more fatal errors] 2016-12-05T06:30:46.219048+00:00 heroku[router]: at=info method=GET path="/assets/intro-bg.jpg"
host=obscure-depths-71348.herokuapp.com
request_id=186c98cc-a9dc-4348-9f24-8bdcde8b6380 fwd="153.104.25.21"
dyno=web.1 connect=0ms service=6ms status=404 bytes=1744 2016-12-05T06:30:46.338582+00:00 heroku[router]: at=info method=GET path="/fonts/fontawesome-webfont.ttf?v=4.2.0"
host=obscure-depths-71348.herokuapp.com
request_id=ab268eea-397b-486d-b481-bb9baed05b19 fwd="153.104.25.21"
dyno=web.1 connect=0ms service=22ms status=404 bytes=1744 [...] 2016-12-05T06:30:46.414182+00:00 app[web.1]: F, [2016-12-05T06:30:46.414118 #4] FATAL -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/method_override.rb:22:in
call'
2016-12-05T06:30:46.414232+00:00 应用 [web.1]: F,
[2016-12-05T06:30:46.414184 #4] 致命 -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/runtime.rb:22:in
call'
2016-12-05T06:30:46.414289+00:00 app[web.1]: F,
[2016-12-05T06:30:46.414236 #4] FATAL -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in
call' 2016-12-05T06:30:46.414344+00:00应用[web.1]:F, [2016-12-05T06:30:46.414290 #4] 致命 -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
供应商/bundle/ruby/2.2.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/executor.rb:12:in call'
2016-12-05T06:30:46.414409+00:00 app[web.1]: F,
[2016-12-05T06:30:46.414346 #4] FATAL -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/static.rb:136:in
call'
2016-12-05T06:30:46.414467+00:00 应用 [web.1]: F,
[2016-12-05T06:30:46.414403 #4] 致命 -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
供应商/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in
call'
2016-12-05T06:30:46.414526+00:00 app[web.1]: F,
[2016-12-05T06:30:46.414471 #4] FATAL -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:522:in
call'
2016-12-05T06:30:46.414588+00:00 应用 [web.1]: F,
[2016-12-05T06:30:46.414529 #4] 致命 -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
供应商/bundle/ruby/2.2.0/gems/puma-3.6.2/lib/puma/configuration.rb:225:in call'
2016-12-05T06:30:46.414653+00:00 app[web.1]: F,
[2016-12-05T06:30:46.414599 #4] FATAL -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/puma-3.6.2/lib/puma/server.rb:578:in
handle_request'
2016-12-05T06:30:46.414720+00:00 应用 [web.1]: F,
[2016-12-05T06:30:46.414655 #4] 致命 -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/puma-3.6.2/lib/puma/server.rb:415:in
process_client'
2016-12-05T06:30:46.414794+00:00 app[web.1]: F,
[2016-12-05T06:30:46.414727 #4] FATAL -- :
[1362654e-c7e4-45ff-bef6-a4150f2ac88c]
vendor/bundle/ruby/2.2.0/gems/puma-3.6.2/lib/puma/server.rb:275:in
block in run' [...] 2016-12-05T06:30:46.211389+00:00 heroku[路由器]: at=info method=GET path="/welcome/js/jquery.js"
host=obscure-depths-71348.herokuapp.com
request_id=46da25e7-77dd-4270-984d-30350b1517df fwd="153.104.25.21"
dyno=web.1 connect=0ms service=31ms status=404 bytes=1744

这是根 html 的 sn-p。另外,如果有人也可以向我解释一下,我的锚链接也不起作用:

home.html.erb:

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>United Cycling</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/landing-page.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <!-- Navigation -->
    <nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
        <div class="container topnav">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand topnav" href="#">United Cycling</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <%= link_to("About", {}, :name => "about") %> 
                    </li>
                    <li>
                        <%= link_to("Schedule", {}, :name => "schedule") %> 
                    </li>
                    <li>
                        <%= link_to("Contact", {}, :name => "contact") %> 
                    </li>
                    <li> 
                        <a href="/members/live">Live </a> 
                    </li>
                    <% if user_signed_in? %> 
                    <li>
                        <%= link_to "Log Out", destroy_user_session_path, method: :delete %>
                    </li>
                    <% end %> 
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>


    <!-- Header -->
    <a name="about"></a>
    <div class="intro-header">
        <div class="container">

            <div class="row">
                <div class="col-lg-12">
                    <div class="intro-message">
                        <h1>United Cycling</h1>
                        <h3>Est 2012</h3>
                        <hr class="intro-divider">
                        <ul class="list-inline intro-social-buttons">
                            <li>
                                <% if !user_signed_in? %> 
                                <a href="/users/sign_up" class="btn btn-default btn-lg"><span class="network-name">Sign Up</span></a>
                            </li>
                            <li>
                                <a href="/users/sign_in" class="btn btn-default btn-lg"><span class="network-name">Log In</span></a>
                            </li>
                            <% end %> 
                        </ul>
                    </div>
                </div>
            </div>

        </div>
...

这是我的 Gemfile,我可能会怀疑有问题:

    source 'https://rubygems.org'

ruby '2.2.4'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'devise', '~> 4.2'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development



group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'

end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

提前谢谢你!

【问题讨论】:

    标签: ruby-on-rails heroku deployment


    【解决方案1】:

    如果您已执行以下操作,请尝试:

    • 运行迁移

      heroku run rake db:migrate
      
    • 重启测功机

      heroku restart -a app_name
      

      或

      Heroku Dashboard > Your App > More > Restart all dynos

    【讨论】:

      猜你喜欢
      • 2018-06-10
      • 2016-01-06
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2016-12-25
      • 2015-01-28
      • 2019-11-11
      • 2015-10-23
      相关资源
      最近更新 更多