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
For some reason, restarting the rails server fixed this issue.
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).
Full app reset fixed it ... should have been some other gem that screwed it up !
How do you do a full app reset?
+1 Devise is not generating registration path using activeadmin
@cpatil is correct. Restarting the rails server will fix the problem. Happened to me as well.
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 />
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'.
Thank You!
I was having the same issue as @cpatil
server restart worked for me :+1:
thank you!!!
Yes server re start worked me, but anyone would like to help me out with .. what caused the issue in the first place?
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.
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
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!
I had the same issue as others had and restarting the rails server fixed the problem for me.
Most helpful comment
For some reason, restarting the rails server fixed this issue.