I'd like to pass custom params when user submits a form. I found this question but I still didn't get it to work.
These are my params on the form page: {"email"=>"[email protected]", "controller"=>"devise/passwords", "action"=>"new"}
Here's my form :
%h2 Forgot your password?
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| =
f.error_notification
.form-inputs
= f.input :email, required: true, autofocus: true, input_html: { value: params[:email] }
.form-actions
= f.button :button, 'Submit', type: 'submit', name: 'email', value: params[:email]
Was this behaviour depreciated at some point or am I doing something wrong? I'm using ruby 2.5.1 and rails 5.2.
Just declare your after password reset path so that you can pass a param :
def after_sending_reset_password_instructions_path_for(resource_name)
my_path(email: resource.email)
end
This should work if your route to your successful password reset page is a collection
path. If it is a member
path, then just add resource like :
def after_sending_reset_password_instructions_path_for(resource_name)
my_path(resource, email: resource.email)
end
But I dont recommend using a member
because it could leak data.