dimanche 13 août 2017

rails how to reject updating when a parameter is missing

i'm kind of new to rails and i want to require a user to input his current_password before updating his infos. I know this can be achieved through devise but i want to do it without devise because i'm having a really hard time modifying the devise.

what i have in mind is something like this:

def update

        @edi_user = EdiUser.find(@trader_edi_user.edi_user_id)
        @edi_user.update_attributes(edi_user_params.reject_if{ |attr| params['current_password'].blank? })

        redirect_to :back
    end

i know this code is wrong, but is this kind of logic possible in rails?

Or can anybody help me how to code the right syntax?

thank you in advance

Aucun commentaire:

Enregistrer un commentaire