LearningRoR
LearningRoR

Reputation: 27212

Missing template with Devise custom registration controller

When using recaptcha for Devise I have to make a new custom registrations controller and my issue is I get a missing template error when their is an error for the email, password or password confirmation because its hitting a route that doesn't even exist.

Template is missing

Missing template registrations/new

The recaptcha works on its own error and renders back to the same page but not for the others.

class RegistrationsController < Devise::RegistrationsController

  def create
    if verify_recaptcha
        super
    else
        flash.delete :recaptcha_error
        build_resource
        clean_up_passwords(resource)
        flash[:alert] = "There was an error with the recaptcha code below."
        render :template => '/devise/registrations/new'  
    end
  end
end

devise_for :users, :controllers => { :registrations => "registrations" }

It should be hitting the same page the recaptcha does on errors ('/devise/registrations/new')How do I correct this issue?

Thanks.

Upvotes: 2

Views: 6359

Answers (2)

Sambit
Sambit

Reputation: 454

Add following line to your config/application.rb file

config.paths['app/views'] << 'app/views/devise'

Upvotes: 0

cailinanne
cailinanne

Reputation: 8372

Try moving the templates from /views/devise/registrations to just /views/registrations. (And changing the reference in your code from /devise/registrations/new to just /registrations/new.)

Upvotes: 7

Related Questions