Rails 一个有趣的 Strong Parameters 示例

juanito · November 05, 2013 · Last by hbin replied at November 07, 2013 · 2169 hits

我跟苍老师是否可以结婚?

> params = ActionController::Parameters.new(marriage: ['Juanito Fatas', '蒼井そら'])
=> { "marriage" => ["Juanito Fatas", "蒼井そら"] }
> params.permit(:marriage)
=> Unpermitted parameters: marriage

为什么!为什么!😱

原来少了栋房子呀 😓,哎。。。

> params.permit(marriage: [])
=> { "marriage" => ["Juanito Fatas", "蒼井そら"] }

来自:http://juanitofatas.com/2014/01/03/strong-parameters/

我寂寞寂寞就好

恭喜发财

You need to Sign in before reply, if you don't have an account, please Sign up first.