Heroku的:ActionController的:: RoutingError(无路由匹配[GET] QUOT; /nav/_nav.html") [英] Heroku: ActionController::RoutingError (No route matches [GET] "/nav/_nav.html")

查看:263
本文介绍了Heroku的:ActionController的:: RoutingError(无路由匹配[GET] QUOT; /nav/_nav.html")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了阿尔伯特排的 AngularJS教程:学习与建立现代角Web应用程序和Rails 的按照指示。使用的WEBrick和工头时我的应用程序在本地使用。部署相同的应用程序来的Heroku之后然而,我跑进用下面的语句AngularJS问题:

I have completed Albert Pai’s AngularJS Tutorial: Learn to Build Modern Web Apps with Angular and Rails following the instructions. My app works locally when using WEBrick and Foreman. However after deploying the same app to Heroku, I ran into problems with the following AngularJS statement:

< D​​IV NG-包括=导航/ _nav.html'>< / DIV>

作为Heroku的服务器 _nav.html 部分观点是找不到的。所以,我得到以下错误:

as at Heroku server the _nav.html partial view isn’t found. So I get the following error:

GET http://fathomless-sands-8666.herokuapp.com/nav/_nav.html 404 (Not Found)

截图(我的思念,让登录和注册导航栏,设备宝石时):

Screenshot (I’m missing the navbar that allows login and registration, Device gem is used):

application.html.erb

<!DOCTYPE html>
<html>
<head>
 <title>FlapperNews</title>
  <%= stylesheet_link_tag    'application', media: 'all' %>
  <%= javascript_include_tag 'application' %>
  <%= csrf_meta_tags %>
</head>
<body ng-app="flapperNews">
    <p class="notice"><%= notice %></p>
    <p class="alert"><%= alert %></p>
    <div class="col-md-6 col-md-offset-3">
      <div ng-include="'nav/_nav.html'"></div>
      <ui-view></ui-view>
    </div>
</body>
</html>

_nav.html

<div class="collapse navbar-collapse pull-right" ng-controller="NavCtrl">
  <ul class="nav navbar-nav">
    <li><a href="#/home">Home</a></li>
    <li ng-hide="signedIn()"><a href="#/login">Log In</a></li>
    <li ng-hide="signedIn()"><a href="#/register">Register</a></li>
    <li ng-show="signedIn()"><a href="#/">{{ user.username }}</a></li>
    <li ng-show="signedIn()"><a ng-click="logout()">Log Out</a></li>
  </ul>
</div>

Heroku的日志:

2015-02-23T12:26:14.936469+00:00 heroku[router]: at=info method=GET path="/assets/application-71f8573cbf92d37602f8bd1449f54ed5.js" host=fathomless-sands-8666.herokuapp.com request_id=6695089f-3134-4397-81da-6832439bc1a4 fwd="212.149.201.185" dyno=web.1 connect=0ms service=10ms status=200 bytes=166290
2015-02-23T12:26:15.938797+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=fathomless-sands-8666.herokuapp.com request_id=61831df5-456c-492b-a315-f0c13faa64cf fwd="212.149.201.185" dyno=web.1 connect=0ms service=3ms status=200 bytes=143
2015-02-23T12:26:15.957956+00:00 heroku[router]: at=info method=GET path="/nav/_nav.html" host=fathomless-sands-8666.herokuapp.com request_id=c40773c6-2f68-4533-b2a3-d9a1bad30ce7 fwd="212.149.201.185" dyno=web.1 connect=0ms service=59ms status=404 bytes=1531
2015-02-23T12:26:15.898369+00:00 app[web.1]: source=rack-timeout id=c40773c6-2f68-4533-b2a3-d9a1bad30ce7 wait=2ms timeout=20000ms state=ready
2015-02-23T12:26:15.935577+00:00 app[web.1]: source=rack-timeout id=61831df5-456c-492b-a315-f0c13faa64cf wait=2ms timeout=20000ms state=ready
2015-02-23T12:26:15.955427+00:00 app[web.1]: 
2015-02-23T12:26:15.955433+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/nav/_nav.html"):
2015-02-23T12:26:15.955437+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'

的routes.rb

FlapperNews::Application.routes.draw do
  devise_for :users
  root to: 'application#angular'
  resources :posts, only: [:create, :index, :show] do
    resources :comments, only: [:show, :create] do
      member do
        put '/upvote' => 'comments#upvote'
      end
    end

    member do
      put '/upvote' => 'posts#upvote'
    end
  end

这是部署到Heroku上的code可以在Github上找到:的https://github.com/jyrkim/flapper-news/blob/master/app/views/layouts/application.html.erb我也创建Procfile并设置彪马宝石作为Heroku的指示:的https://devcenter.heroku.com/articles/getting-started-with-rails4#specify-ruby-version-in-app我没有在指定的Gemfile唯一是Ruby的版本。我的Ubuntu使用的Ruby版本2.1和Heroku上要使用2.0版我的应用程序。 (也许这可能会导致问题)

The code that was deployed to Heroku can be found at Github: https://github.com/jyrkim/flapper-news/blob/master/app/views/layouts/application.html.erb I have also created Procfile and set the Puma gem as instructed at Heroku: https://devcenter.heroku.com/articles/getting-started-with-rails4#specify-ruby-version-in-app The only thing that I didn’t specify in the Gemfile was the Ruby version. My Ubuntu uses Ruby version 2.1 and Heroku wants to use version 2.0 for my app. (Maybe that could cause the problem)

如果有人有什么线索可能在Heroku的环境中导致了问题,那么请让我知道 - 谢谢

If someone has a clue what might be causing the problem at Heroku environment, then please let me know - Thanks.

推荐答案

它看起来像在本地运行的资产precompilation当你第一次部署到Heroku的(因为你在你的有旧文件公开/资产目录),但由于向网站并重新部署到Heroku的进一步的修改都没有再次运行。

It looks like you ran an asset precompilation locally when you first deployed to Heroku (because you have older files in your public/assets directory) but have not run it again since making further changes to the site and re-deploying to Heroku.

这意味着你的pre-编译JS是超前于你的 application.html.erb 。您是从服务的Heroku的JS面前导航/ _nav.html 编译创建以来一直没有更新。

This means that your pre-compiled JS is out of step with your application.html.erb. The JS your are serving from Heroku was compiled before nav/_nav.html was created and has not been updated since.

您可以运行资产pre-编译再次从本地:

You can either run the asset pre-compilation again locally:

RAILS_ENV=production bundle exec rake assets:precompile

或删除公共/资产目录,提交和重新部署,使Heroku的执行资产precompilation一步,塞在编译期间部署的一部分。这样做,这样意味着你不必担心未来本地运行rake任务。

Or remove the public/assets directory, commit and redeploy so that Heroku performs the asset precompilation step as part of the deployment during slug compilation. Doing it this way means that you don't have to worry about running the rake task locally in future.

请参阅 https://devcenter.heroku.com/articles/rails-asset-pipeline

这篇关于Heroku的:ActionController的:: RoutingError(无路由匹配[GET] QUOT; /nav/_nav.html&quot;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆