Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `registration_path' #1773

Closed
cpatil opened this issue Apr 3, 2012 · 15 comments
Closed

undefined method `registration_path' #1773

cpatil opened this issue Apr 3, 2012 · 15 comments

Comments

@cpatil
Copy link

cpatil commented Apr 3, 2012

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
Copy link
Author

cpatil commented Apr 3, 2012

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

@cpatil cpatil closed this as completed Apr 3, 2012
@vala
Copy link

vala commented Apr 16, 2012

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
Copy link

vala commented Apr 16, 2012

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

@gadamsthe
Copy link

How do you do a full app reset?

@pedroviana
Copy link

+1 Devise is not generating registration path using activeadmin

@ardeearam
Copy link

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

@sandrocarval
Copy link

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 />

@januszm
Copy link

januszm commented Aug 8, 2013

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

@ponyczek
Copy link

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

@tamiki
Copy link

tamiki commented May 15, 2015

thank you!!!

@vamsipavanmahesh
Copy link

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

@alliesground
Copy link

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.

@nezirz
Copy link

nezirz commented Dec 20, 2017

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
Copy link

nezirz commented Dec 20, 2017

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!

@KingsleyMcSimon
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests