Users on my page can sign up with their phone numbers. If they forget the password, it should be resent via SMS.
My goal is to have on my registrations/new.html.haml page a link, which will trigger some custom controller (which sends a SMS with a password).
I thought of replacing Devise's passwords_controller.rb edit action, but it seems not to be triggered:
class Front::Users::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
def new
p "hello"
super
end
end
-> "Hello" never appears in the logs.
After that I created a custom controller "profile_controller.rb" with route as following: get 'reset_password', to: 'front/profile#change_password'
Now, my sessions/new looks like this:
=form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
.section.section-inset-1
.container
.row
.col-xs-12.col-md-8.col-md-offset-2
%section
%h4 Sign in
.rd-mailform.row.flow-offset-6
.col-xs-12.col-sm-6
=f.text_field :phone, placeholder: "Phone number", data: { constraints: "@NotEmpty" }, autofocus: true, id: "standard_order_phone"
.col-xs-12.col-sm-6
=f.password_field :password, placeholder: "Password", data: { constraints: "@Password" }, class: "form-input", autocomplete: "off"
.col-xs-12.col-sm-6.text-left
%label.mfCheckbox
=f.check_box :remember_me, class: 'mfCheckbox__input'
%span Remember me
.col-xs-12.col-sm-6.text-right
%label.mfCheckbox#send_password
=link_to 'Send password via SMS', reset_password_path(phone: params["user[phone]"]), method: :get
%section.section-inset-3
.row.offset-5
.col-xs-12
=f.submit 'Sign in', class: 'btn btn-sm btn-min-width btn-success'
%section.section-inset-3
.row.ud_mt_4em
%h6 Not signed up yet?
.row.offset-5
=link_to 'Sign up', new_user_registration_path, method: :get, class: 'btn btn-sm btn-min-width btn-success-mod-1'
So, basically what I need right now is to somehow pass the :phone param from this form to link_to helper. I tried all results from googling "rails pass params to link_to", but when calling my profile_controller
class Front::ProfileController < FrontController
def change_password
logger.debug "This is Patrick with params: #{params}"
end
end
Params do not contain the phone number. How can I achieve passing the params or elsewise the desired functionality?