-1

I added the devise gem to my rails app. Then I appended the url with user/sign_up as that is self created by the app. Then the following page shows up - enter image description here

I am unable to locate the file with the following code.

This is what the bottom of the page looks like - enter image description here

Do let me know what more information I can provide.

Thanks for your time and help.

EDIT 1 Added routes.rb for your reference

Rails.application.routes.draw do
  devise_for :users
    root to: 'pages#home'
    get 'about', to: 'pages#about'
    resources :contacts, only: :create
    get 'contact-us', to: 'contacts#new', as: 'new_contact'
end

EDIT 2- Added the following piece of code to my application.html.erb file

<% if user_signed_in? %>
  <%= link_to "Log Out", destroy_user_session_path, method: :delete, class: "btn btn-default navbar-btn" %>
<% else %>
  <%= link_to "Log In", new_user_session_path, class: "btn btn-default navbar-btn" %>
  <%= link_to "Sign Up", new_user_registration_path, class: "btn btn-default navbar-btn" %>
<% end %>

And a page displayed the error: NoMethodError in Pages#home(as in the image added) with the subsequent lines- Showing /home/ec2-user/environment/saasapp/app/views/layouts/application.html.erb where line #31 raised: undefined method `user_signed_in?' for #<#Class:0x000000047464c8:0x007f399e3e7ab8> Did you mean? user_session_url

Mad Yo
  • 29
  • 1
  • 1
  • 6
  • Instead of copying an images representing errors, send it as text. It makes it easier to be found for future users. – Marek Lipka Sep 17 '20 at 13:42
  • This error is inside the Devise conroller (in the Gem), specifically (as it says) in `devise_controller.rb` line 102. You wont be able to find it unless you open the Gem `bundle open devise`. But that won't solve the issue, there is something out of line with your setup. – Rockwell Rice Sep 17 '20 at 13:49
  • Did you take a look [here](https://www.google.com/search?q=devise+is_navigational_format+error)? There seem to be some promising posts on this error. – jvillian Sep 17 '20 at 14:05

1 Answers1

0

Did you follow devise docs for installing devise in rails? There is something to do with your routes.rb. Go through this article https://guides.railsgirls.com/devise and follow all the steps carefully. Also post your routes.rb maybe the problem is with your routes. Thanks, This type of question is asked here just try those step as well. See this link as well.

fahad
  • 18
  • 8
  • 1
    Out of curiosity, what led you to conclude that there is something with the OP's `routes.rb`? It *might* help future searchers to understand how you figured this out. – jvillian Sep 17 '20 at 14:09
  • @fahad Thanks! I followed the steps mentioned in the first link you have provided and the same error comes up. I have added my routes.rb code for your reference. – Mad Yo Sep 17 '20 at 17:01
  • @jvillian it was routing error so, There must be some problem with the routes whenever these type of errors popup. As questioner was using devise so, there must be some devise routes error in the code. Thanks. – fahad Sep 18 '20 at 10:44
  • @fahad I followed the guidance on the links you provided and my rails server stopped working. I have undone the changes and added some code to the application.html.erb file and now any page doesn't load. From my understanding, the system seems to be lacking the 'sign in' and 'log out' methods that are associated with the Devise gem. Please let me know if I am misunderstanding and how to progress. Cheers – Mad Yo Sep 18 '20 at 15:30