Ask A Question

Notifications

You’re not receiving notifications from this thread.

Problem with the load of view of sign_in with Devise Rails 5

Thomaz Wanderbruck Schmidt asked in Rails

I have the views of devise in views/users, but I have one layout for all app in aplication.html.erb, but the devise i dont want to renderize with this layout, so I create a sessions controller and add this line code render "layouts/sessions" where i create a layout special for login with the form default of devise and I will customize. But when I add the authentication in application_controller:

before_action :authenticate_user!

I have the views of devise in views/users, but I have one layout for all app in aplication.html.erb, but the devise i dont want to renderize with this layout, so I create a sessions controller and add this line code render "layouts/sessions" where i create a layout special for login with the form default of devise and I will customize. But when I add the authentication in application_controller

before_action :authenticate_user!

the view return the follow error:

NoMethodError in #
Showing /home/thomazws/Documentos/rails/projetohroV2/app/views/layouts/sessions.html.erb where line #5 raised:

undefined method `name' for nil:NilClass
Extracted source (around line #5):
3
4
5
6
7
8

<%= render partial: "layouts/site/navbar"%>

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


<%= f.label :email %>

<%= f.email_field :email, autofocus: true, autocomplete: "email" %>

Rails.root: /home/thomazws/Documentos/rails/projetohroV2

Application Trace | Framework Trace | Full Trace
app/views/layouts/sessions.html.erb:5:in _app_views_layouts_sessions_html_erb__3586321389248541598_69851658500860'
app/controllers/sessions_controller.rb:2:in
class:SessionsController'
app/controllers/sessions_controller.rb:1:in `'

sessions_controller.rb

class SessionsController < Devise::SessionsController
render "layouts/sessions"
end

strange that when I take the devise form and <% = render partial: "layouts / site / navbar"%> and put the login again it loads together with the navbar that is in the partial, however if I update the page or I stop the server and turn it back on it returns the error.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.