【问题标题】:RAILS ERROR : SyntaxError in ResumesController#newRAILS ERROR : SyntaxError in ResumesController#new
【发布时间】:2014-05-09 21:25:12
【问题描述】:

每当我启动我的 rails 服务器并运行 resume builder 时,我都会收到以下错误:

root/app/controllers/resumes_controller.rb:38:语法错误,意外的keyword_end

root/app/controllers/resumes_controller.rb:121:语法错误,意外的keyword_end

root/app/controllers/resumes_controller.rb:131: 语法错误,意外的 $end,期待关键字_end

这是我的 resumes_controller.rb 文件第 25 - 40 行

     # GET /resume/1
     # GET /resume/1.json
     def show
@resume = current_user.resumes.find(params[:id])
layout = current_user.resumes.find(params[:id]).layout || "application"
respond_to do |format|
  format.html # show.html.erb
  format.json { render json: @resume }
  format.pdf do
    render :pdf => "file_name",
    :layout   => "resumes/#{layout}.pdf.erb",
    :temwkhtmltopdfplate => "resumes/pdf_layouts/show.html.erb",
    :wkhtmltopdf  => Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s,
  end
end
end

这是我的第 111 - 124 行

     def short_link
@resume = Resume.where(short_link: params[:short_link]).first
layout = @resume.layout || "application"
respond_to do |format|
  format.html {  render layout: @resume.layout }# show.html.erb
  format.pdf do
    render :pdf => "file_name",
    :layout   => "resumes/#{layout}.pdf.erb",
    :template => "resumes/pdf_layouts/show.html.erb",
    :wkhtmltopdf  => Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s,
  end
end
end 

最后是第 126-131 行

      private
  def correct_user
    user = User.find(params[:user_id])
    redirect_to root_path unless current_user?(user)
  end
  end

请帮忙!

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3


    【解决方案1】:

    二先:后去昏迷:

    :wkhtmltopdf  => Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s,
    

    最后一个:需要更多上下文 - 你在某处有未关闭的块。

    【讨论】:

    • Wow Awesome 解决了前两个问题,就像你说的谢谢。虽然最后一个错误仍然存​​在
    • @HabeebSulu - 我们需要查看更多最后的代码。不幸的是,这个错误通常很难找到——你在某个地方打开了一个尚未关闭的块。它可能是类定义、某种方法、任何do end 循环。无法从您发布的代码中找到错误。
    • 感谢 BroiSatse 错误已经消失,现在又出现了一个新错误。我在 localhost 上测试一个脚本,而且我是 Ruby 的新手。这是错误显示 C:/Sites/Resumonk-master/app/views/resumes/_form.html.erb 其中第 67 行引发:root//app/views/resumes/_form.html.erb:67: 语法错误,意外的keyword_do_block ...= f.fields_for :educations, do |education_form| @output_buf...
    • @HabeebSulu - 在:education之后摆脱昏迷:= f.fields_for :educations, do
    • 你太棒了,我非常感谢你
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多