繁体   English   中英

部署Ruby On Rails项目时发生意外的INDENT

[英]Unexpected INDENT while Deploying Ruby On Rails Project

当我第一次部署到新服务器时,出现此错误。 我已经包含了它所引用的文件。 以及部署过程中显示的错误。

任何帮助,将不胜感激。

    servers: ["108.235.52.160"]
    [108.235.52.160] executing command
 ** [out :: 108.235.52.160] rake aborted!
 ** [out :: 108.235.52.160] SyntaxError: unexpected INDENT
 ** [out :: 108.235.52.160] (in /home/deployer/loadmax/releases/20140328165152/a
pp/assets/javascripts/subscriptions.js.coffee)
 ** [out :: 108.235.52.160]
 ** [out :: 108.235.52.160] Tasks: TOP => assets:precompile:primary

文件:

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
$(document).ready ->
  if window.location.search.substring(1) == "demo=true"
    $("select#sub").val("6")
    $(".price").hide()
  $('#package').change ->
    if $('#package option:selected').val() == "4" or $('#package option:selected').val() == "6"
      $(".price option[value='299']").remove()
      $(".price option[value='59.99']").remove()
    else
      $(".price").append("<option value='299'>299 Annually</option>")
      $(".price").append("<option value='59.99'>59.99 Monthly</option>")
  $('.recurrence').change ->
    if $('.recurrence option:selected').val() == 'Annual'
      $(".price").append("<option value='299'>299</option>")
      $(".price").append("<option value='239'>239</option>")
      $(".price").append("<option value='199'>199</option>")
      $(".price option[value='39.99']").remove()
    else
      $(".price").append("<option value='39.99'>39.99</option>")
      $(".price option[value='299']").remove()
      $(".price option[value='239']").remove()
      $(".price option[value='199']").remove()
  $('#subscription_tier').change ->
    if $('#subscription_tier option:selected').val() == '4'
      $("label[for='recurrence_recurrence']").hide()
      $(".recurrence").hide()
      $("label[for='price_point_Price point']").hide()
      $(".price").hide()
    else
      $("label[for='recurrence_recurrence']").show()
      $(".recurrence").show()
      $("label[for='price_point_Price point']").show()
      $(".price").show()
  $('#sub').change ->
    if $('#sub option:selected').val() == "6"
      $(".price").hide()
      $(".recurrence").hide()
    else
      $(".price").show()
      $(".recurrence").show()
  $('.email').change ->
    email = $(this).val()
    $.get "/users/?email="+email, (user) ->
      if user.length == 0
        $('#alert_placeholder').hide()
        $('.submit').show()
      else
        error_message = "This email address is already in use."
        $('#alert_placeholder').show()
        $('#alert_placeholder').
        html("<div class='alert alert-error alert-block'><h4 class='alert-heading'>Duplicate Email!</h4><span>#{error_message}</span></div>")
        $('.submit').hide()
   $('.name').change ->
      name = $(this).val() ->
    name = name.replaceAll("[^A-Za-z0-9]", "");
        if $(this).name.val() ->
          $('#alert_placeholder').hide()
          $('.submit').show()
      else
        error_message = "No comma's allowed in form."
        $('#alert_placeholder').show()
        $('#alert_placeholder').
        html("<div class='alert alert-error alert-block'><h4 class='alert-heading'>Comma Error!</h4><span>#{error_message}</span></div>")
        $('.submit').hide()
  $('.mc').change ->
    mc = $(this).val()
    unless mc==''
      $.get "/companies/?mc="+mc, (companies) ->
        unless companies.length == 0
          for company in companies
            if company['status'] == true
              #if there is an active company with this mc number, then we throw
              #an error instructing the Sales Agent to refer the customer to an
              #Account Manager.
              error_message="This company has an active account in loadmax. Please refer the customer to an Account Manager"
              $('#alert_placeholder').
              html("<div class='alert alert-error alert-block'><h4 class='alert-heading'>Active Company Error!</h4><span>#{error_message}</span></div>")
              active_company_exists = true
          unless active_company_exists
            popover_text = 'There exist inactive account(s) in our system with the
            same MC number:<table class="table table-striped">'
            li = []
            for company in companies
              #If we've reached here, then there exists an inactive account with
              #the same MC number. The get request bellow will always return
              #one company, as should be obvious.
              temp = ''
              $.ajax
                url: "/subscriptions?company_id=#{company['id']}"
                type: "GET"
                async: false
                success: (subscription) ->
                  href = "http://secure.loadmax.com/subscriptions/dashboard/"+
                  subscription[0]['id']+"?paysysid="+subscription[0]['paysysid']
                  temp += '<tr><td><b>'+company['name']+'</b><td>'
                  temp += "<td><a href="+href+"> Use </a></td></tr>"
              .done ->
                li.push temp
            popover_text += li.join " "
            popover_text += "</table>"
            $('.mc-popover').popover(html: true, placement: 'right', content: popover_text )
            $('.mc-popover').popover("show")
        else

Coffeescript网站帮助了很多人。

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
$(document).ready ->
  if window.location.search.substring(1) == "demo=true"
    $("select#sub").val("6")
    $(".price").hide()
  $('#package').change ->
    if $('#package option:selected').val() == "4" or $('#package option:selected').val() == "6"
      $(".price option[value='299']").remove()
      $(".price option[value='59.99']").remove()
    else
      $(".price").append("<option value='299'>299 Annually</option>")
      $(".price").append("<option value='59.99'>59.99 Monthly</option>")
  $('.recurrence').change ->
    if $('.recurrence option:selected').val() == 'Annual'
      $(".price").append("<option value='299'>299</option>")
      $(".price").append("<option value='239'>239</option>")
      $(".price").append("<option value='199'>199</option>")
      $(".price option[value='39.99']").remove()
    else
      $(".price").append("<option value='39.99'>39.99</option>")
      $(".price option[value='299']").remove()
      $(".price option[value='239']").remove()
      $(".price option[value='199']").remove()
  $('#subscription_tier').change ->
    if $('#subscription_tier option:selected').val() == '4'
      $("label[for='recurrence_recurrence']").hide()
      $(".recurrence").hide()
      $("label[for='price_point_Price point']").hide()
      $(".price").hide()
    else
      $("label[for='recurrence_recurrence']").show()
      $(".recurrence").show()
      $("label[for='price_point_Price point']").show()
      $(".price").show()
  $('#sub').change ->
    if $('#sub option:selected').val() == "6"
      $(".price").hide()
      $(".recurrence").hide()
    else
      $(".price").show()
      $(".recurrence").show()
  $('.email').change ->
    email = $(this).val()
    $.get "/users/?email="+email, (user) ->
      if user.length == 0
        $('#alert_placeholder').hide()
        $('.submit').show()
      else
        error_message = "This email address is already in use."
        $('#alert_placeholder').show()
        $('#alert_placeholder').
        html("<div class='alert alert-error alert-block'><h4 class='alert-heading'>Duplicate Email!</h4><span>#{error_message}</span></div>")
        $('.submit').hide()
   $('.name').change ->
      name = $(this).val() ->
        name = name.replaceAll("[^A-Za-z0-9]", "");
        if $(this).name.val()
          $('#alert_placeholder').hide()
          $('.submit').show()
        else
          error_message = "No comma's allowed in form."
          $('#alert_placeholder').show()
          $('#alert_placeholder').
          html("<div class='alert alert-error alert-block'><h4 class='alert-heading'>Comma Error!</h4><span>#{error_message}</span></div>")
          $('.submit').hide()
  $('.mc').change ->
    mc = $(this).val()
    unless mc==''
      $.get "/companies/?mc="+mc, (companies) ->
        unless companies.length == 0
          for company in companies
            if company['status'] == true
              #if there is an active company with this mc number, then we throw
              #an error instructing the Sales Agent to refer the customer to an
              #Account Manager.
              error_message="This company has an active account in loadmax. Please refer the customer to an Account Manager"
              $('#alert_placeholder').
              html("<div class='alert alert-error alert-block'><h4 class='alert-heading'>Active Company Error!</h4><span>#{error_message}</span></div>")
              active_company_exists = true
            unless active_company_exists
              popover_text = 'There exist inactive account(s) in our system with the
              same MC number:<table class="table table-striped">'
              li = []
              for company in companies
                #If we've reached here, then there exists an inactive account with
                #the same MC number. The get request bellow will always return
                #one company, as should be obvious.
                temp = ''
                $.ajax
                  url: "/subscriptions?company_id=#{company['id']}"
                  type: "GET"
                  async: false
                  success: (subscription) ->
                    href = "http://secure.loadmax.com/subscriptions/dashboard/"+
                    subscription[0]['id']+"?paysysid="+subscription[0]['paysysid']
                    temp += '<tr><td><b>'+company['name']+'</b><td>'
                    temp += "<td><a href="+href+"> Use </a></td></tr>"
                .done ->
                  li.push temp
              popover_text += li.join " "
              popover_text += "</table>"
              $('.mc-popover').popover(html: true, placement: 'right', content: popover_text )
              $('.mc-popover').popover("show")
        else

UNEXPECTED INDENT的直接含义是代码行缩进过多,但也可能由于前一行发生语法错误而被观察到。

为了找到此错误,您应该先清理代码。 为了使CoffeeScript(以及我认为所有的语言,但这尚有争议)要保持可读性和可维护性,应将其分解为一些小函数。 您在所附代码段的底部附近有大约8个压痕级别的事实将使您很难识别任何错误。

如果将上面的高度嵌套的代码分解为较小的函数后错误仍然存​​在(我怀疑会这样;清理后问题很可能会暴露出来),则可以开始使用存根替换这些函数的内容。

找到令人讨厌的5行代码后,请专心凝视代码,直到问题解决为止。

如有必要,加咖啡。

PS如果在\\tab字符和two spaces缩进之间的代码文件中存在差异,我过去也遇到过此问题。 因此,如果您的IDE允许,请启用空白显示或执行其可用的任何空白清除选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM