我已将我的项目上传到 heroku,但出现此错误:NoMethodError in Items#hype_item
并且undefined method "link" for nil:NilClass
. 当我使用 localhost 时,它可以在我的计算机上运行。
我已经这样做了:
- heroku 运行 rake db:create
- herouk 运行 rake db:migrate
- heroku 重启
...并阅读了很多关于这个问题的帖子,但它并没有解决它。
有什么建议么?
这是日志
2012-12-14T11:54:02+00:00 app[web.1]: Processing by ItemsController#hype_item as HTML
2012-12-14T11:54:03+00:00 app[web.1]: Rendered items/hype_item.html.erb within layouts/application (75.2ms)
2012-12-14T11:54:03+00:00 app[web.1]: Completed 500 Internal Server Error in 405ms
2012-12-14T11:54:03+00:00 app[web.1]:
2012-12-14T11:54:03+00:00 app[web.1]: ActionView::Template::Error (undefined method `link' for nil:NilClass):
2012-12-14T11:54:03+00:00 app[web.1]: 6: <p><div id="abc"><%= raw @item.link %></div></p>
2012-12-14T11:54:03+00:00 app[web.1]: 8: </div>
2012-12-14T11:54:03+00:00 app[web.1]: 3:
2012-12-14T11:54:03+00:00 app[web.1]: app/views/items/hype_item.html.erb:6:in `_app_views_items_hype_item_html_erb___686068816707788662_29579640'
2012-12-14T11:54:03+00:00 app[web.1]:
2012-12-14T11:54:03+00:00 app[web.1]: 4: <div class="modal hide" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="tr">
2012-12-14T11:54:03+00:00 app[web.1]: 5: <div class="modal-body">
2012-12-14T11:54:03+00:00 app[web.1]: 7: </div>
2012-12-14T11:54:03+00:00 app[web.1]:
2012-12-14T11:54:03+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.erb (18.7ms)
2012-12-14T11:54:03+00:00 heroku[router]: at=info method=GET path=/ host=enigmatic-tor-2280.herokuapp.com fwd=84.48.62.139 dyno=web.1 queue=0 wait=0ms connect=16ms service=773ms status=500 bytes=26039
2012-12-14T11:54:03+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (29.9ms)
2012-12-14T11:54:03+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
...和gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem "less-rails", "~> 2.2.6"
gem 'therubyracer'
gem 'bcrypt-ruby', :require => 'bcrypt'
group :assets do
gem 'sass-rails', '~> 3.2.3' #mulig denne må flyttes ut av asset group for å virke
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
gem 'twitter-bootstrap-rails'
end
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
gem 'thin'
gem 'jquery-rails'
hype_item.html.erb
<div id="counter"></div>
<div id="play_button"> <a id="play" role="button"><%= image_tag("Play.png")%></a></div>
<div class="modal hide" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="tr">
<div class="modal-body">
<p><div id="abc"><%= raw @item.link %></div></p>
</div>
</div>
如果您需要查看更多文件,请告诉我,我不确定什么是相关的。