3

I'm trying to style my devise forms. So far I have done so by adding classes and IDs into the forms found in app/views/devise. However, I haven't been able to find where the form for /users/password/new (new_password_path) exists. It renders a button with "send me reset password instructions" on it; I did a search through my app and can't find where that comes from... Would that be in the Devise gem itself?

TL/DR: How can I style the forgot password view?

Thanks in advance.

redbeardNinja
  • 43
  • 1
  • 5
  • 1
    `http://stackoverflow.com/questions/6607834/rails-3-devise-manually-change-password` refer this – SNEH PANDYA Dec 27 '13 at 20:28
  • My view at users/password/new looks like the below. What I'm wondering is where this is being generated from. It seems pretty standard, and was autogenerated for me; I just don't know how to edit it. `%h2 Forgot your password? = form_for(resource, as: resource_name, url: password_path(resource_name), html: { :method => :post }) do |f| = devise_error_messages! %div = f.label :email %br/ = f.email_field :email %div= f.submit "Send me reset password instructions"` – redbeardNinja Dec 27 '13 at 20:48

2 Answers2

6

Similar to the Registrations and Sessions behaviour Devise provides a default Passwords view and controller that isn't automatically generated in your own application folder structure.

To override the Forgotten Password view create new.html.erb in a views/devise/passwords folder. You can see the default views on Devise's GitHub: https://github.com/plataformatec/devise/tree/master/app/views/devise/passwords

To override the PasswordsController create passwords_controller.rb in your app/controllers folder that inherits from the Devise controller and override whatever you need. For example to supply a non-default layout.

class PasswordsController < Devise::PasswordsController
    include ApplicationHelper
    layout "minimal"
end

You then need to change your routes.rb file to specify the custom controller should be used by devise:

devise_for :users, :controllers => {:registrations => "registrations", :sessions => "sessions", :passwords => "passwords"}
Tim Williams
  • 318
  • 2
  • 6
0

In you development.rb

config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { 
:address => 'smtp.gmail.com', 
:port => your_port_num, 
:domain => 'site.com',
:user_name => 'admin@site.com',
:enable_starttls_auto => true,
:password => 'none' }

Your path with be redirected in mail.

SNEH PANDYA
  • 797
  • 7
  • 22
  • Thanks, but that's not really what I'm looking for. I haven't configured my mailer yet; I'm just wondering how to style the page users/password/new, which is where a user inputs his/her email to be sent to the mailer. See my comment above... I can access that page in the browser, but I have no idea where it is coming from as I cannot find it in my app... – redbeardNinja Dec 27 '13 at 20:51