获取特定参数的价值-Rails [英] Get value of a specific param - Rails
本文介绍了获取特定参数的价值-Rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在特定的控制器中,我具有以下参数列表:
In a specific controller I have the below list of params:
Parameters: {"user"=>"{\"id\":32,\"email\":\"test@test.com\",\"created_at\":\"2014-04-10T13:13:40.000Z\",\"updated_at\":\"2014-04-11T18:10:15.000Z\"}"}
例如,如何获取电子邮件的价值?
How I can get the value of email for example?
推荐答案
您的值看起来像json.
You value looks like json.
所以试试这个
user_params = ActiveSupport::JSON.decode(params[:user])
user_params[:email]
或
require 'json'
user_params = JSON.parse(params[:user])
user_params[:email]
这篇关于获取特定参数的价值-Rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文