Make blank params[] nil

前端 未结 13 672
半阙折子戏
半阙折子戏 2020-12-13 18:36

When a user submits a form and leaves certain fields blank, they get saved as blank in the DB. I would like to iterate through the params[:user] collection (for example) an

13条回答
  •  我在风中等你
    2020-12-13 18:59

    I generalized an answer and made a hook/extension that can be used as an initializer. This allows it to be used across multiple models. I've added it as part of my ActiveRecordHelpers repo on GitHub

提交回复
热议问题