How to make changes to strong parameters (change to lowercase)

后端 未结 4 1430
予麋鹿
予麋鹿 2020-12-16 18:42

So I am familiarising myself with both rails and of course rails 4.

So this is what I have at the bottom of my controller

def post_params
  params.re         


        
4条回答
  •  悲&欢浪女
    2020-12-16 19:17

    Better You can use before_create callback to update the value.

    like,

    before_create :check_params
    
    def check_params   
       self.category.downcase!     
    end
    

提交回复
热议问题