1

When I fill-out the "sign up" page in my project developed with ROR and devise, and submit, I get the error above. Can anyone help with a solution?

I am a noob just started learning ROR with the free YT course "Learn Ruby on Rails - Full Course", the objective is to create a "friends" address book, and then allow people to sign up and create their own address book. By following the instructions I have installed ROR on my Windows 10 machine and created the address book using scaffold. Then styled the views / webpages using bootstrap. It is all working on my local machine as shown in the video.

Now I'm at the part of installing devise for User Management. I've installed that gem according to the YT instructor, and checked it against the "getting started" guide for devise. Added some of the new views to the nav bar (i.e. Sign Up, Sign In, Sign Out, Edit Profile) according to the new routes created.

Now when the instructor uses the "sign up" page on the YT video it shows a "successful..." notice. When I try, the Sign Up page displays correctly, but when hitting submit I get the error:

"NoMethodError in Devise::RegistrationsController#create undefined method `user_url' for #Devise::RegistrationsController:0x0000000000cbc0 "

There are then loads of lines of stuff (should I paste that?) and then this red box with:

Exception Causes ActionView::MissingTemplate: Missing template devise/registrations/create, devise/create, application/create with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}. Searched in: * "C:/railsfriends/friends/app/views" * "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/devise-4.8.1/app/views" * "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actiontext-7.0.0/app/views" * "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionmailbox-7.0.0/app/views" Did you mean? devise/registrations/edit devise/registrations/new devise/mailer/confirmation_instructions devise/mailer/reset_password_instructions devise/passwords/edit devise/mailer/email_changed

I note that although this YT guide is just over a year old, some of the installation instructions were already out of date and I had to search to install ROR properly. So, maybe something with his devise instructions is out of date now?

I looked at the other questions already here regarding this subject and they were not relevant that I could see. This one is over 7 years old and seems to be a problem with encryption (I don't have that error come up), and this one doesn't seem to solve my issue either. I even found this answer on reddit which isn't relevant to my issue, but I note that the person answering says the user should never use Scaffold again!

In my searching I noticed an option to roll back the db migration. Is that something that could work in case I somehow didn't follow the instructions to a "T" and the solution to this issue can't be found?

Thanks for your help.

Muffler
  • 11
  • 2

3 Answers3

1

According to the error message you provide, looks like you're either defining wrong routes or you've probably customized the controller of Devise::RegistrationsController. If you've configure the routes with devise correctly, I guess the problem comes from the later one.

Make sure you've defined the routes with the instruction from devise and where you want to redirect users after registrations:

# routes.rb
resource :user # <= here

check if the routes are correctly defined:

# in the terminal app
rake routes
# => lists the routes you've defined

And make sure you've built the related controllers.

JFree
  • 86
  • 4
1

You can solve this issue by adding data: {turbo: false} to the path helpers in the views.

For example app/views/devise/registrations/new.html.erb

you can change

`<%= form_for(resource, as: resource_name, url: registration_path(resource_name) do |f| %>` 

to appear like

 <%= form_for(resource, as: resource_name, url:registration_path(resource_name), data: {turbo: false}) do |f| %>
Dennis Kamau
  • 81
  • 1
  • 6
  • this worked for me thank you. https://stackoverflow.com/questions/66615478/turbo-rails-with-devise-does-not-redirect-consistently-rails-6-1-3-devise-4-7-3 for people who want more context. – i0x539 Oct 03 '22 at 17:39
1

I've found this solution worked for me as I was getting the same exact error on sign up.

Shut down the server. Navigate to config/initializers/devise.rb

I changed line #266 to:

config.navigational_formats = ['*/*', :html, :turbo_stream]

I then did rails db:migrate in the terminal and restarted the server. Seems to be working now.