0

我之前看到过类似的问题,但它没有解决我的特定问题。我已经完成了 Michael Hartl 的 Rails 教程的第 5 章,虽然到目前为止它很棒,但我目前遇到了一个奇怪的问题。在本地测试了应用程序(并发现一切都按预期工作)后,我将应用程序推送到 Heroku。现在,当我单击 Heroku 页面页脚中的 About 或 Contact 页面链接时,我会收到一条消息说“我们遇到了问题”。所有其他链接都有效,我检查了页脚部分文件,看起来很好。

日志似乎没有告诉我任何有用的信息。我将发布日志文件、页脚、Gemfile 和路线。任何帮助将不胜感激,谢谢!

路线

SampleApp::Application.routes.draw do
  get "users/new"

  root  to: 'static_pages#home' 



  match '/signup', to: 'users#new'

  match '/help',    to: 'static_pages#help'
  match '/about',   to: 'static_pages#About'
  match '/contact', to: 'static_pages#contact'

end

页脚部分

<footer class="footer">
<small>
    <a href="http://railstutorial.org/">Rails Tutorial</a>
    by Michael Hartl
</small>
<nav>
    <ul>
        <li><%= link_to "About", about_path %></li>
        <li><%= link_to "Contact", contact_path %></li>
        <li><a href="http://news.railstutorial.org/">News</a>
        </ul>
    </nav>
</footer>

宝石文件

source 'https://rubygems.org'
ruby '1.9.3'

gem 'rails', '3.2.12'
gem 'bootstrap-sass', '2.1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do

gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
end 

# Gems used only for assets and not required
# in production environments by default.
group :assets do
    gem 'sass-rails', '3.2.5'
    gem 'coffee-rails', '3.2.2'
    gem 'uglifier', '1.2.3'
end


gem 'jquery-rails', '2.0.2'

group :test do
gem 'capybara', '1.1.2'
end

group :production do
gem 'pg', '0.12.2'
end

日志(更新:我有一组新日志,似乎它声称缺少模板,但并没有丢失)我仍然不明白发生了什么。

2013-05-03T16:31:41.516275+00:00 app[web.1]: ActionView::MissingTemplate (Missing template static_pages/about, application/about with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
2013-05-03T16:31:41.516275+00:00 app[web.1]: ):
2013-05-03T16:31:41.516275+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/path_set.rb:58:in `find'
2013-05-03T16:31:41.516275+00:00 app[web.1]:   * "/app/app/views"
2013-05-03T16:31:41.516275+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/lookup_context.rb:109:in `find'
2013-05-03T16:31:41.516275+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/rendering.rb:110:in `_render_template'
2013-05-03T16:31:41.516275+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/renderer/renderer.rb:36:in `render_template'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/renderer/renderer.rb:17:in `render'
2013-05-03T16:31:41.516275+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/renderer/template_renderer.rb:34:in `determine_template'
2013-05-03T16:31:41.516275+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/renderer/template_renderer.rb:10:in `render'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/streaming.rb:225:in `_render_template'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/rendering.rb:16:in `render'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/rendering.rb:103:in `render_to_body'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/rendering.rb:88:in `render'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
2013-05-03T16:31:41.516531+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/benchmark.rb:5:in `ms'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:39:in `render'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action'
2013-05-03T16:31:41.516766+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:414:in `_run__2984696832344586189__process_action__1371554362507721148__callbacks'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
2013-05-03T16:31:41.516989+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
2013-05-03T16:31:41.517214+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'

同样,一切都在本地工作,所以我不明白可能出了什么问题。我确实看到它似乎正在查看我也不明白的 app/app/views。任何有经验的人的帮助将不胜感激。

编辑:

contact.html.erb 的内容

<% provide(:title, 'Contact Us') %>

<h1>Contact Us</h1>
<p>
  The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
  is a project to make a book and screencasts to teach web development
  with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
  is the sample application for the tutorial.
</p>

static_pages_controller.rb 的内容

class StaticPagesController < ApplicationController

  def home
  end

  def help
  end

  def about
  end

  def contact
  end

end
4

1 回答 1

2

如果你还没有让它工作,请确保你已经暂存了所有要推送的文件git(也许使用git add .),然后提交(`git commit -m "foo")然后推送到 Heroku。

于 2013-05-28T14:49:37.003 回答