ruby on rails - Require Nested Params in Controller -
i need know how require nested params in ruby on rails api. have method set param whitelisting below:
def user_params params.require(:user).permit(:email, :password, :profile => [:name, :birthdate, :addy]) end however, makes profile permitted param, not required one. want profile required. it's allowed have no other nested params (essentially nil), must still required. how accomplish this?
most "required" portion going come actual model. so, in case, go user.rb file , add following.
validates :profile, presence: true
is you're talking about? usually, you're going want allow params in controller , perform validations , stuff in actual model file.
Comments
Post a Comment