我的rails应用程序中的语法错误在哪里?

时间:2015-06-18 15:17:36

标签: ruby-on-rails controller

以下是我的webhooks_controller.rb:

class WebhooksController < ApplicationController
  before_action :auth_anybody!
  skip_before_filter :verify_authenticity_token

  def tx
    if params[:type] == "transaction" && params[:hash].present?
      AMQPQueue.enqueue(:deposit_coin, txid: params[:hash], channel_key: "satoshi")
      render :json => { :status => "queued" }
  end
end

我收到以下错误:

webhooks_controller.rb:10: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)

一切都很好看。我的错误在哪里?

1 个答案:

答案 0 :(得分:1)

您缺少end子句的if。正确的代码是

def tx
  if params[:type] == "transaction" && params[:hash].present?
    AMQPQueue.enqueue(:deposit_coin, txid: params[:hash], channel_key: "satoshi")
    render :json => { :status => "queued" }
  end
end