在rails 3.2.19中无法将Symbol转换为Integer

时间:2015-02-10 05:33:43

标签: ruby-on-rails ruby-on-rails-3

ParticipantsController

def save_bmi_measurement

  return error_response(INVALID_REQUEST, "required parameters are missing") unless params[:access_code].present? && params[:auth_token].present? && params[:weight].present? && params[:w_unit].present? && params[:h_unit].present? && params[:bmi].present?  

  @participantBmiLog = ParticipantBmiLog.new(:weight => params[:weight], :w_unit => params[:w_unit],:h_unit=>:params[:h_unit],:height=>params[:height],:bmi=>params[:bmi],:measured_date=>params[:measured_date])

  #...

participant.rb

has_many :bmi_logs,:class_name => "ParticipantBMILog", :dependent => :destroy

ParticipantBmiLog

belongs_to :participant

belongs_to :research_info  

attr_accessible :weight,:w_unit,:h_unit,:height,:bmi,:measured_date,:participant_id,:research_info_id

我在rails 3.2.19中获得了can't convert Symbol into Integer。请帮帮我。

1 个答案:

答案 0 :(得分:0)

看到这个你正在写符号作为符号

:h_unit=>:params[:h_unit] 

应该是

:h_unit=>params[:h_unit]