0

Missing template users/registrations/new with:

{ :locale=>[:en], 
  :formats=>[:html], 
  :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]

Following

redirect_to new_user_registration_url

works fine however

render new_user_registration_url

gives above error.

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController

  def facebook

    @user, new_record = User.find_or_create(request.env["omniauth.auth"], current_user)

    if @user.persisted?

      if new_record

        sign_in @user

        redirect_to basic_profile_detail_path

      else

        sign_in_and_redirect @user, :event => :authentication 

        set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?

      end

    else

      session["devise.facebook_data"] = request.env["omniauth.auth"]

      render new_user_registration_url

    end

  end

end

Here's my controller however before saving facebook auth data I need to ask for contact number to the user and rest of the form needs to be filled up from @user data. Hence I can't use redirect in this scenario.

Marek Lipka
  • 50,622
  • 7
  • 87
  • 91
Ajay Modi
  • 27
  • 1
  • 8
  • 1
    Show your controller code. And, BTW, you misuse `render`, so I would propose some reading, for example: http://guides.rubyonrails.org/layouts_and_rendering.html – Marek Lipka Jan 23 '14 at 10:29
  • figured out I need to use render 'devise/registrations/new' as it is inherited from Devise controller. – Ajay Modi Jan 23 '14 at 11:35

3 Answers3

0

Missing template users/registrations/new means that you have to create a template file under app/views/users/registrations/ named new.html. (see formats in the exception).

Nevertheless, as @Marek Lipka said, you misuse render so you should take a look at the following guide.

Pierre-Louis Gottfrois
  • 17,561
  • 8
  • 47
  • 71
0

90% of the time I see this error it's because I should be using

redirect_to '/some-unique-url-in-my-app`

instead of

render '/some-unique-url-in-my-app`

The remaining times it's because there is no html.erb file that matches what the app is expecting to find. For example, if you had render "articles/show", then your app would expect to find a file called app/views/articles/show.html.erb

There's another good example here

stevec
  • 41,291
  • 27
  • 223
  • 311
0

I had the same issue while upgrading an old Rails 2.3 application to Rails 7.

Maybe you only need to remove the extension from the template file.

The old Rails 2.3 code was:

render :template => 'companies/list.erb' and return

The Rails 7 code that worked for me is:

render template: 'companies/list' and return
DanieleV
  • 11
  • 3