当我第一次部署到新服务器时,我收到此错误。我已经包含了它引用的文件。以及部署过程中显示的错误。
任何帮助将不胜感激。
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
答案 0 :(得分:1)
UNEXPECTED INDENT
的直接含义是一行代码缩进太多,但也可能因为前一行发生语法错误而被观察到。
为了找到此错误,您应该首先清理代码。对于CoffeeScript(以及所有语言,在我看来,但这有争议)保持可读性和可维护性,它应该被分解为小功能。事实上,您在附加片段底部附近看起来大约有8级缩进,这会使任何错误难以识别。
如果在将上面的高度嵌套代码分解为较小的函数(我怀疑它会出现问题后,问题可能会在清理时显露出来)之后错误仍然存在,那么您可以开始用存根替换这些函数的内容。
找到违规的5行代码后,请专注地查看代码,直到问题出现为止。
如有必要,请加入咖啡。
<强> P.S。强>
如果\tab
字符和two spaces
缩进之间的代码文件中存在差异,我过去也遇到过此问题。因此,如果您的IDE允许,请启用空白显示或执行它可用的任何空白清理选项。