title: Rails devise sign in not working
body: <p>I have a problem - recently I created User with devise gem. Sadly, the "sign_in" button does not really work properly - after visiting sin_in page and clicking on sign in button nothing happens! It does not matter if I enter my email and password for signing in. I checked the logs and after clicking sign up button there are no changes in logs or on the terminal with server running on! So I guess it does not send any request? But the problem occurs only after I visit the login page the first time, after refreshing it all works as intended. Please help me, I have no idea what may cause such weird behaviour.<Br></p>
  
  <p>EDIT: Oddly enough, I noticed that only after heading to login page from my main page the problem occurs - If I proceed to login page simply by typing its address instead of clicking on sing in link in browser it works. But addresses after both actions are the same, so I have no idea... There are my welcome view:</p>
  
  <pre><code>&lt;div id="homepage"&gt;
    &lt;header class="cf"&gt;
      &lt;h1 class="logo"&gt;&lt;%= link_to "E-LEARN", "#" %&gt;&lt;/h1&gt;
      &lt;nav&gt;
        &lt;ul&gt;
          &lt;li&gt;&lt;%= link_to "Watch guides", root_path %&gt;&lt;/li&gt;
          &lt;% unless user_signed_in? %&gt;
            &lt;li&gt;&lt;%= link_to "Log In", new_user_session_path %&gt;&lt;/li&gt;
          &lt;% else %&gt;
            &lt;li&gt;&lt;%= link_to "Log Out", destroy_user_session_path, method: :delete %&gt;&lt;/li&gt;
            &lt;li&gt;&lt;%= link_to "Settings", edit_user_registration_path %&gt;&lt;/li&gt;
            &lt;li&gt;&lt;%= link_to "My Account", current_user %&gt;&lt;/li&gt;
          &lt;% end %&gt;
          &lt;li&gt;&lt;%= link_to "Add tutorial", "#" %&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/nav&gt;
    &lt;/header&gt;
    &lt;div class="wrapper-skinny" id="welc"&gt;
      &lt;h1&gt;Learn programming from others, or share your experience with novices.&lt;/h1&gt;
    &lt;/div&gt;
    &lt;div class="buttons"&gt;
      &lt;%= link_to "Learn something", new_user_registration_path , class: "button button-highlight" %&gt;
      &lt;%= link_to "Share experience", "#", class: "button button-dark"%&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><br>
  There are my files:<br>
  application controller:</p>
  
  <pre><code> class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
    before_filter :configure_permitted_parameters, if: :devise_controller?
  
    protected
  
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :description, :email, :password, :password_confirmation, :current_password) }
    end
  end
  </code></pre>
  
  <p>migration:</p>
  
  <pre><code>class DeviseCreateUsers &lt; ActiveRecord::Migration
    def change
      create_table(:users) do |t|
        ## Database authenticatable
        t.string :email,              null: false, default: ""
        t.string :encrypted_password, null: false, default: ""
  
        ## Recoverable
        t.string   :reset_password_token
        t.datetime :reset_password_sent_at
  
        ## Rememberable
        t.datetime :remember_created_at
  
        ## Trackable
        t.integer  :sign_in_count, default: 0, null: false
        t.datetime :current_sign_in_at
        t.datetime :last_sign_in_at
        t.string   :current_sign_in_ip
        t.string   :last_sign_in_ip
  
        ## Confirmable
        # t.string   :confirmation_token
        # t.datetime :confirmed_at
        # t.datetime :confirmation_sent_at
        # t.string   :unconfirmed_email # Only if using reconfirmable
  
        ## Lockable
        # t.integer  :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
        # t.string   :unlock_token # Only if unlock strategy is :email or :both
        # t.datetime :locked_at
  
  
        t.timestamps null: false
      end
  
      add_index :users, :email,                unique: true
      add_index :users, :reset_password_token, unique: true
      # add_index :users, :confirmation_token,   unique: true
      # add_index :users, :unlock_token,         unique: true
    end
  end
  </code></pre>
  
  <p>User.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
    has_many :guides
    validates :username, presence: true, length: { minimum: 5 }
  end
  </code></pre>
  
  <p>routes:</p>
  
  <pre><code>Rails.application.routes.draw do
  
    root to: 'welcome#index'
    devise_for :users
  
    resources :users, only: [:show, :index] do
      resources :guides
    end
  
  end
  </code></pre>
  
  <p>and gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '4.2.2'
  gem 'sass-rails', '~&gt; 5.0'
  gem 'uglifier', '&gt;= 1.3.0'
  gem 'coffee-rails', '~&gt; 4.1.0'
  gem 'jquery-rails'
  gem 'turbolinks'
  gem 'sqlite3'
  gem 'jbuilder', '~&gt; 2.0'
  gem 'sdoc', '~&gt; 0.4.0', group: :doc
  gem 'bcrypt', '~&gt; 3.1.7'
  gem 'devise', '~&gt; 3.5', '&gt;= 3.5.2'
  gem 'paperclip', '~&gt; 4.3', '&gt;= 4.3.1'
  
  group :development, :test do
    gem 'byebug'
    gem 'web-console', '~&gt; 2.0'
    gem 'spring'
  end
  
  group :development do
    gem 'sqlite3'
  end
  
  group :production do
    gem 'pg', '0.17.1'
    gem 'rails_12factor'
  end
  </code></pre>
  
  <p>routes:</p>
  
  <pre><code>                 Prefix Verb   URI Pattern                               Controller#Action
                      root GET    /                                         welcome#index
          new_user_session GET    /users/sign_in(.:format)                  devise/sessions#new
              user_session POST   /users/sign_in(.:format)                  devise/sessions#create
      destroy_user_session DELETE /users/sign_out(.:format)                 devise/sessions#destroy
             user_password POST   /users/password(.:format)                 devise/passwords#create
         new_user_password GET    /users/password/new(.:format)             devise/passwords#new
        edit_user_password GET    /users/password/edit(.:format)            devise/passwords#edit
                           PATCH  /users/password(.:format)                 devise/passwords#update
                           PUT    /users/password(.:format)                 devise/passwords#update
  cancel_user_registration GET    /users/cancel(.:format)                   devise/registrations#cancel
         user_registration POST   /users(.:format)                          devise/registrations#create
     new_user_registration GET    /users/sign_up(.:format)                  devise/registrations#new
    edit_user_registration GET    /users/edit(.:format)                     devise/registrations#edit
                           PATCH  /users(.:format)                          devise/registrations#update
                           PUT    /users(.:format)                          devise/registrations#update
                           DELETE /users(.:format)                          devise/registrations#destroy
               user_guides GET    /users/:user_id/guides(.:format)          guides#index
                           POST   /users/:user_id/guides(.:format)          guides#create
            new_user_guide GET    /users/:user_id/guides/new(.:format)      guides#new
           edit_user_guide GET    /users/:user_id/guides/:id/edit(.:format) guides#edit
                user_guide GET    /users/:user_id/guides/:id(.:format)      guides#show
                           PATCH  /users/:user_id/guides/:id(.:format)      guides#update
                           PUT    /users/:user_id/guides/:id(.:format)      guides#update
                           DELETE /users/:user_id/guides/:id(.:format)      guides#destroy
                     users GET    /users(.:format)                          users#index
                      user GET    /users/:id(.:format)                      users#show
  </code></pre>
  
  <p>and my login view (devise/sessions/new.html.erb):</p>
  
  <pre><code>&lt;%= render 'shared/header' %&gt;
  
  &lt;div class="banner" &gt;
  &lt;/div&gt;
  
  &lt;div class="wrapper-skinny"&gt;
    &lt;h2&gt;Log in&lt;/h2&gt;
  
    &lt;%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %&gt;
      &lt;div class="field"&gt;
        &lt;%= f.label :email %&gt;&lt;br /&gt;
        &lt;%= f.email_field :email, autofocus: true %&gt;
      &lt;/div&gt;
  
      &lt;div class="field"&gt;
        &lt;%= f.label :password %&gt;&lt;br /&gt;
        &lt;%= f.password_field :password, autocomplete: "off" %&gt;
      &lt;/div&gt;
  
      &lt;% if devise_mapping.rememberable? -%&gt;
        &lt;div class="field" id="checkbox"&gt;
          &lt;%= f.check_box :remember_me %&gt;
          &lt;%= f.label :remember_me %&gt;
        &lt;/div&gt;&lt;/div&gt;&lt;br&gt;
      &lt;% end -%&gt;
  
      &lt;div class="actions"&gt;
        &lt;%= f.submit "Log in" %&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;%= render "devise/shared/links" %&gt;
  &lt;/div&gt;
  </code></pre>