2014-11-17 34 views
0

即使我的「visit_id」在我的數據庫中被定義爲一個整數,我仍然收到這個錯誤。任何人有什麼理由?我的本地env是sqlite3並且工作正常,但是當我推送到heroku時,我得到這個...下面是我的表單代碼。Heroku PG錯誤,沒有顯示在開發中

PG :: InvalidTextRepresentation:錯誤:布爾型輸入無效語法: 「visit_id」

控制器

 def show 
     @visit = Visit.find_by :visit_id 

     respond_with(@payment) 
     end 

     def new 
     @visit = Visit.find(params[:visit_id]) 
     @payment = @visit.build_payment 
     end 

     def create 
     @payment = Payment.new(payment_params) 
     api = UrlApi.new() 
     url = api.unique_url 
     @payment.update_attribute :atapi, url 
     @payment.save 
     if @payment.save 
      respond_with(@payment) 
     else 
      redirect_to edit_payment_path, :alert => "Unable to update user." 
     end 

形式付款

<div class="row form"> 
     <div class="col-sm-6 row-col"> 
      <div class="box"> 
       <!--visits form --> 
       <%= bootstrap_form_for(@payment) do |f| %> 
       <%= f.hidden_field :user_id, :value => current_user.id %> 
       <%= f.hidden_field :visit_id %> 
       <%= f.text_field :coupon_code %> 
       <%= f.check_box :coupon_valid %> 
       <%= f.check_box :paid %> 
      </div> 
     </div> 

     <div class="col-sm-6"> 
      <div class="box"> 
       <%= f.text_field :atapi %> 
      <%= f.select :seen, 
       [['Yes',true],['No',false]], 
       label: "Patient seen" 
       <%= f.submit %> 
       <% end %> 
       <div class="row submit"> 
        <div class="col-md-3 right"> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
+0

什麼是導致該錯誤的特定代碼?順便說一下,在SQLite上開發和在PostgreSQL上部署是個不錯的主意,ActiveRecord並沒有提供任何有用的可移植性。 –

+0

我沒有看到來自heroku日誌的特定錯誤代碼?這是錯誤開始的第一行。我理解做pg和sqlite3的不好的想法,我的計劃是將開發移植到pg儘快。我目前正在同時在學習這個應用程序的過程中學習PG,但我還不知道如何才能在本地正確設置它。 – keith

回答

0

你的問題很可能就在這裏:

@visit = Visit.find_by :visit_id 

既然你給find_by東西是不是一個Hash,它可能要求它to_s和生產這樣的SQL:

select visits.* from visits where visit_id limit 1 

在PostgreSQL,WHERE子句中的每個組件是一個布爾值,自PostgreSQL有一個真正的布爾類型,它會嘗試解釋標識符visit_id作爲一個布爾值,但visit_id列是一個整數,所以你得到:

invalid input syntax for type boolean: "visit_id"

SQL中的SQLite的解釋比PostgreSQL的和它寬鬆了不少:

1.1 Boolean Datatype

SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).

所以說where some_integer_column是絕對意義上的SQLite。

我猜你show控制器應該開始:

@visit = Visit.find_by(:visit_id => params[:visit_id]) 

@visit = Visit.find(params[:visit_id]) 
+0

比我更聰明的人來救援!第二個固定它,謝謝你的時間! – keith