0
我想在方法模型中保存這些值,但它不能保存。我不知道我是否要使用text_field_tag或其他東西。使用參數,但我不能得到價值
查看:
<div class="field">
<%= f.label 'Nemónico' %>
<%= f.text_field :nemo %>
</div>
控制器:
n = params[:nemo]
Change.saveHist(current_user.email,n,DateTime.now.to_date)
型號:
def self.saveHist(session,nemo,date)
h = DawHist.create(hsesion: session, hregnemo: nemo,hdate: date)
end
Rails's'development.log'中的參數hash的內容是什麼? – 2015-04-05 17:07:07
使用create!而不是通過創建來了解錯誤。你可能有驗證錯誤 – 2015-04-05 17:21:11
@architgupta我dit它和日誌中的錯誤是 'ActiveRecord :: RecordInvalid(驗證失敗:nemo不能爲空): app/models/change.rb:8:in saveHit' app/controllers/registrers_controller.rb:52:在block中更新' app/controllers/registrers_controller.rb:48:in update'' – vimx 2015-04-05 17:45:33