Rails 500服务器错误

时间:2014-02-13 22:46:17

标签: javascript ruby-on-rails ajax ruby-on-rails-3 ruby-on-rails-4

我在导航器控制台中遇到500内部错误。

在服务器控制台中:

在359ms内完成500内部服务器错误

  

ActionView :: MissingTemplate(缺少模板问题/ vote_for,   application / vote_for with {:locale => [:en],:formats => [:js,:html],   :handlers => [:erb,:builder,:coffee]}。搜索范围:*   “/ home / seif / Documents / ROR / Voting_trial / StackUnderflow / app / views”):
  app / controllers / questions_controller.rb:90:在`vote_for'

     

渲染   /home/seif/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/missing_template.erb   在救援/布局(0.5ms)内

问题是什么?

这是vote_for动作:

def vote_for
  logger.info "***vote for***!!!"
  logger.info params[:id]
  @quest_vote_for = Question.find(params[:id])
  current_user.vote_exclusively_for(@quest_vote_for)
  respond_to do |format|
    format.js
    format.html
  end
end

这是观看电话:

<%=link_to raw( vote_for, vote_for_question_path(@question), :remote => true,:class =>"btn btn-default btn-lg" %>

1 个答案:

答案 0 :(得分:0)

更清楚......错误是因为无法找到模板。

首先,如果你想支持js和html响应,那么你需要一个模板。

所以你需要以下其中一项:

/app/views/questions/vote_for.html.erb
/app/views/application/vote_for.html.erb (bad practice)

以下之一

/app/views/questions/vote_for.js.erb
/app/views/questions/vote_for.js.coffee
/app/views/application/vote_for.js.erb (bad practice)
/app/views/application/vote_for.js.coffee (bad practice)