簡體   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