0
votes

I'm trying to figure out the following problem. Could someone help me out in the beginning of learning rails?

Environment

ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

Rails 5.1.4

devise (4.3.0)

Current behavior

Following result is displayed in browser window after pressing 'Sign up' -link.

ActionController::UrlGenerationError in Devise::Sessions#new

No route matches {:action=>"new", :controller=>"devise/flight_records"}

Following code in application.html.erb

<%= link_to 'Add New', {:controller => 'flight_records', :action => 'new'} %>
<%= link_to 'Logbook', {:controller => 'flight_records', :action => 'index'} %>
<%= link_to 'Sign Up', new_user_registration_path %>
<%if user_signed_in? %>
  <%= link_to "Sign Out", destroy_user_session_path, method: :delete  %>
<%else %>
  <%= link_to "Log In", new_user_session_path %>
<% end %> 

Following code in routes.rb

Rails.application.routes.draw do
   devise_for :users
   resources :flight_records 

   #get 'welcome/index'

   root 'flight_records#index'

Following routes in rake:

rake routes

enter image description here

2

2 Answers

0
votes

You are trying to create a new user. so, It should go to devise#registration with POST action. By default devise signup creates a user record, if you wants to create flight_records, modify the form to point to flight_records create method.

0
votes

Now it works! Working version of the application.html.erb

      <%= link_to "Sign Out", destroy_user_session_path, method: :delete  %>
  <%else %>
      <%= link_to "Log In", new_user_session_path %>
  <% end %>