开发者

Missing template with Devise custom registration controller

开发者 https://www.devze.com 2023-04-03 20:12 出处:网络
When using recaptcha for Devise I have to make a new custom registrations controller and my issue is I get a missing template err开发者_Python百科or when their is an error for the email, password or p

When using recaptcha for Devise I have to make a new custom registrations controller and my issue is I get a missing template err开发者_Python百科or 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.


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.)


Add following line to your config/application.rb file

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

0

精彩评论

暂无评论...
验证码 换一张
取 消