我想獲取從活動記錄特定的列值特定的列值,我寫在視圖的SQL查詢,但我沒有得到的數據... new.html.erb取從活動記錄軌道
<%= f.text_field :pan_number, { value: OfferLetter.where(["candidate_id = (?)",params[:userID]]).select("pan_number").first, placeholder: 'COYP1234IN', class: 'form-control' } %>
然後,我就按照我的觀點的結果
OfferLetter.where(["candidate_id = ?",17]).select("pan_number")
OfferLetter Load (0.3ms) SELECT `offer_letters`.`pan_number` FROM `offer_letters` WHERE (candidate_id = 17)
=> #<ActiveRecord::Relation [#<OfferLetter id: nil, pan_number: "COPYD123IN">]>
請幫助我,我在紅寶石是新軌道上,並告訴我在哪裏,我是錯的,什麼是問題
嘗試此,<(%)= f.text_field:PAN_NUMBER, {value:OfferLetter.where([「candidate_id =(?)」,params [:userID]])。first.select(「pan_number」)。first,placeholder:'COYP1234IN',class:'form-control'}% > – Navin
當我們where子句中我們得到一個active :: record :: collection時,試着在獲得單個記錄後在那裏查詢像添加。首先它 – Navin