devise icon indicating copy to clipboard operation
devise copied to clipboard

undefined method `registration_path'

Open cpatil opened this issue 14 years ago • 15 comments

Using devise 2.0.4 with Rails 3.2.2 and hitting /users/sign_up (development mode) , I get

undefined method `registration_path' for #<#<Class:0x007f936ab09c08>:0x007f936b049088>

Extracted source (around line #3):

1: <h2>Sign up</h2> 2: 3: <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> 4: <%= devise_error_messages! %> 5: 6: <div><%= f.label :email %><br />

more info at - https://gist.github.com/2295672

cpatil avatar Apr 03 '12 21:04 cpatil

For some reason, restarting the rails server fixed this issue.

cpatil avatar Apr 03 '12 21:04 cpatil

I'm having the same issue with the same Devise/Rails versions, but restarting the server doesn't change anything.

rake routes gives me the right routes but it seems like the registration_path helper (so the others like password_path) aren't loaded inside the view.

Furthermore, devise routes (not only the helpers) are only loaded if I edit the routes.rb file and save it (so it is reloaded).

vala avatar Apr 16 '12 12:04 vala

Full app reset fixed it ... should have been some other gem that screwed it up !

vala avatar Apr 16 '12 15:04 vala

How do you do a full app reset?

gadamsthe avatar Mar 10 '13 19:03 gadamsthe

+1 Devise is not generating registration path using activeadmin

pedroviana avatar Apr 01 '13 17:04 pedroviana

@cpatil is correct. Restarting the rails server will fix the problem. Happened to me as well.

ardeearam avatar Apr 29 '13 02:04 ardeearam

I have the same issue, but restarting the rails server doesn't fix.

In routes.rb, I have:

devise_for :sales
      as :sale do
        get 'sales/edit' => 'devise/registrations#edit', :as => 'edit_sale_registration'
        put 'sales' => 'devise/registrations#update', :as => 'sale_registration'
      end

My view:

<%= link_to t('.change_your_password'), edit_sale_registration_path %>

Error:

 NoMethodError in Devise/registrations#edit

Showing /home/sribeiro/projects/licensor/trunk/licensor/app/views/devise/registrations/edit.html.erb where line #3 raised:

undefined method `registration_path' for #<#<Class:0xa4d9324>:0xa4d5e54>

Extracted source (around line #3):

1: <h2><%= t('.title', :resource => resource_name.to_s.humanize , :default => 'Edit #{resource_name.to_s.humanize}') %></h2>
2: 
3: <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4:   <%= devise_error_messages! %>
5: 
6:   <div><%= f.label :email %><br />

sandrocarval avatar May 06 '13 14:05 sandrocarval

I updated the wiki page https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-password because it is slightly misleading if someone just wants to copy-paste the solution without updating devise views. The problem is the following, you define 'edit_sale_registration' route but if you use default devise edit.html.erb form then you end up with error because the form uses 'registration_path', while it should be 'sale_registration_path'.

januszm avatar Aug 08 '13 15:08 januszm

Thank You! I was having the same issue as @cpatil
server restart worked for me :+1:

ponyczek avatar Sep 18 '14 14:09 ponyczek

thank you!!!

tamiki avatar May 15 '15 09:05 tamiki

Yes server re start worked me, but anyone would like to help me out with .. what caused the issue in the first place?

vamsipavanmahesh avatar Feb 03 '16 05:02 vamsipavanmahesh

I had run rails generate devise:views -v registrations to customise the view, later my decision changed and I removed the views/devise/registration folder and started to get the above mentioned error.

seems like Running rails destroy devise:views -v registrations solved the issue for me.

alliesground avatar Sep 04 '17 14:09 alliesground

Now I have problem within:

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def facebook
    # You need to implement the method below in your model (e.g. app/models/user.rb)
    @user = User.from_omniauth(request.env["omniauth.auth"])

    if @user.persisted?
      sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
      set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
  end

  def failure
    redirect_to root_path
  end
end

Trying to log in as facebook user and all the time I am redirected to devise sign up page. Everything was okay last few months omniauth worked fine, today I just delete my user from db and tried to login/register again.
Hereis my code: https://stackoverflow.com/questions/47905428/rails-devise-omniauth-new-user-registration-url

nezirz avatar Dec 20 '17 12:12 nezirz

I found the reason in user.rb model I had one association belongs_to:somemodel and that I was put there for testing some model relations.

So commenting this line I am logged in by facebook!

nezirz avatar Dec 20 '17 13:12 nezirz

I had the same issue as others had and restarting the rails server fixed the problem for me.

KingsleyMcSimon avatar Apr 24 '20 09:04 KingsleyMcSimon