Rails 一个有趣的 Strong Parameters 示例

juanito · 2013年11月05日 · 最后由 hbin 回复于 2013年11月07日 · 2167 次阅读

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

> 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/

我寂寞寂寞就好

恭喜发财

需要 登录 后方可回复, 如果你还没有账号请 注册新账号