This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def show | |
@user = User.find(params[:id]) | |
end | |
def new | |
@user = User.new | |
end | |
def create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < ApplicationController | |
def new | |
end | |
def create | |
user = User.find_by(name: params[:session][:name].downcase) | |
if user && user.authenticate(params[:session][:password]) | |
sign_in user | |
redirect_to user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="center hero-unit"> | |
<h1>The Weekend</h1> | |
<p>shit.</p> | |
<div class="row"> | |
<div class="span6 offset3"> | |
<%= form_for(:session, url: sessions_path) do |f| %> | |
<%= f.text_field :name, :placeholder => "Username or email", | |
title: 'username' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Authentication" do | |
subject { page } | |
describe "signin" do | |
before { visit root_path } | |
it { should have_button('Sign in') } |