i have defined user_params in rails 5, like this:
(我已经在rails 5中定义了user_params,如下所示:)
def training_plan_params
params.require(:training_plan).permit(:training_plan_id, :sport_id, :distance,
lastTrainingStatus:[:duration,:reps,:type,:level],
trainings: [:text, :order, :level],modified:[:level,:duration])
end
but when i send the params to rails, like this:
(但是当我将参数发送到rails时,如下所示:)
{ training_plan: { sport_id: 2, distance: 900 } }
it doesn't retrieve the distance in the controller as integer, like this:
(它不会以整数形式检索控制器中的距离,如下所示:)
=> <ActionController::Parameters {"sport_id"=>"2", "distance"=>"900"} permitted: true>
=> training_plan_params[:distance]
=> "900"
is there a way to keep its type and not converts it to string?
(有没有办法保持其类型,而不是将其转换为字符串?)
ask by socertis translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…