我最近爲我一直在研究的現有應用程序應用程序創建了一個heroku應用程序。我只有一個我想在瀏覽器上看到的html文件。這個文件從我的數據庫中獲取新聞報道(sqlite3 - 應該從技術角度來看是從開發角度來看,我已經用它來配合railstutorial,我根本沒有配置postgres),以及它們相應的圖像和吐出他們到了頁面。這在本地主機上完美運行,但是當我使用'heroku open'進行部署時,我所看到的只是一個空白頁面,並在頁面的頂部添加了標題標籤:'BBC熱門新聞'。就好像應用程序根本不讀取eRB標籤。下面是我的索引視圖html.erb文件中的代碼:RoR應用程序:將應用程序部署到heroku時出現問題
<h1> Top stories from BBC <h1>
<% @stories.each do |story| %>
<% if story.image.nil? %>
<% # do nothing %>
<% else %>
<div>
<h3><%= story.name %></h3>
<p><%= story.summary %></p>
<a href = "<%= story.url %>" >
<img src="<%= story.image %>" />
</a>
</div>
<% end %>
<% end %>
,這裏是我的Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.8'
gem 'feedjira'
gem 'mechanize'
gem 'nokogiri'
# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
我一直使用的Heroku和Git命令,如:
- 混帳推
- git push heroku
- heroku run rake db:migrate
- 耙子資產:預編譯
- git add。/git commit -m/etc。
- 混帳推Heroku的主
即使試圖以多種不同的組合以上後,似乎沒有任何工作。如果能讓我的索引頁在Heroku上正確呈現,我將不勝感激。它可以在本地主機上完美工作。
謝謝,您的幫助將不勝感激!
我認爲問題是與數據庫,無論是你的數據庫是不是在Heroku上配置,或者你的故事是在Heroku數據庫空 – 2014-09-30 18:17:34
你能告訴我們你控制器? – beaglebets 2014-09-30 18:26:19
在config/environments/production.rb文件中,您是否更改了此設置** config.serve_static_assets = true **? – userden 2014-09-30 18:31:40