Search code examples
ruby-on-railsrubyruby-on-rails-4devise

Devise login doesn't work / no error messages


Guys i've looked everywhere to fix this issue but I'm out of luck.

I got a devise login system and i signed up an account admin@admin.com in development and on the log i got the confirmation email and i went to that email and so my account got confirmed. Now when i try to login the console gives me this message:

Started GET "/users/sign_in?utf8=%E2%9C%93&authenticity_token=iHIEXxGHWaIdtAGhcZ7EKvEEEYGmoEfgr1K8NcKb9nFIXuD6dpMVimOO6aBEdZJUWv9Irt%2FT0vnaucjW%2BgmJQQ%3D%3D&user%5Bemail%5D=admin%40admin.com&user%5Bpassword%5D=[FILTERED]&user%5Bremember_me%5D=0&commit=Log+in" for ::1 at 2016-06-01 13:11:54 +0200
Processing by Devise::SessionsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"iHIEXxGHWaIdtAGhcZ7EKvEEEYGmoEfgr1K8NcKb9nFIXuD6dpMVimOO6aBEdZJUWv9Irt/T0vnaucjW+gmJQQ==", "user"=>{"email"=>"admin@admin.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
  Rendered devise/sessions/new.html.erb within layouts/application (3.7ms)
  Rendered partials/_header.html.erb (0.5ms)
  Rendered partials/_menu.html.erb (0.2ms)
  Rendered shared/_breadcrumbs.html.erb (0.0ms)
  Rendered partials/_footer.html.erb (0.0ms)
  Rendered partials/_javascripts.html.erb (0.0ms)
Completed 200 OK in 143ms (Views: 52.6ms | ActiveRecord: 0.0ms)

After this the page just refreshes and i'm not logged in. When i go to resend confirmation instructions it says 'email is already confirmed, try signing in'

My sign in form looks like this:

<% provide(:title, "Sign in") %>
<div class="col-md-12">
  <form class="sign-box">
    <header class="sign-title"> Sign in </header>

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

        <% if devise_error_messages!.present? %>
            <div class="alert alert-warning alert-icon alert-close alert-dismissable fade in" role="alert">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
              <i class="font-icon font-icon-warning"></i>
              <%= devise_error_messages! %>
            </div>
        <% end %>

      <div class="field form-group">
        <%= f.label :email, class: 'float-left' %><br />
        <%= f.email_field :email, class: 'form-control', autofocus: true %>
      </div>

      <div class="field form-group">
        <%= f.label :password, class: 'float-left' %><%= link_to 'Forgot your password?', new_user_password_path, class: 'float-right reset' %>
        <%= f.password_field :password, class: 'form-control', autocomplete: "off" %>
      </div>

      <% if devise_mapping.rememberable? -%>
        <div class="field form-group">
          <div class="checkbox float-left">
            <%= f.check_box :remember_me %>
            <%= f.label :remember_me %>
          </div>
        </div>
      <% end -%>

      <div class="actions">
        <%= f.submit "Log in", class: 'btn btn-rounded' %>
      </div>

        <p class="sign-note">New to our website? <%= link_to "Sign Up", new_user_registration_path %></p>
    <% end %>
  </form>
</div>

What could it be guys? I'm out of options after trying for days.


Solution

  • The answer was rather simple all along

    I had to change <form class="sign-box"> to <div class="sign-box"> cause apparently you can't have a ruby form_for tag inside a html form attribute.