I’m using Devise and Bootstrap in my Rails app
In the Bootstrap navbar i have this login form:
<form class="navbar-form pull-right">
<% if current_user %>
<b><%= link_to current_user.name, current_user %></b>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
<% else %>
<input class="span2" type="text" placeholder="Email">
<input class="span2" type="password" placeholder="Password">
<button type="submit" class="btn"><%= link_to "Sign in", new_user_session_path %></button>
<button type="submit" class="btn"><%= link_to "Register", new_user_registration_path %></button>
<% end %>
</form>
If I enter the email/pass and hit “sign in”, then the page refreshes, but the user session doesn’t start (the user hasn’t been logged in). Am I doing something wrong in this form?
I can sign in using the Devise /sign_in page but i want to be able to do so aswell in my nav bar 🙂
Your form isn’t posting to anything, those link_to tags aren’t really doing anything.
Links aren’t the same as inputs.
Instead you need a form like this:
You’ll need a separate form for registration, I suggest simply linking to another registration page.