Skip to content

Instantly share code, notes, and snippets.

View safarista's full-sized avatar

Nelson Kelem safarista

View GitHub Profile
<h2>Log In</h2>
<%= form_tag sessions_path do %>
<div class="field">
<%= label_tag :user_name %><br>
<%= text_field_tag :user_name, params['user_name'] %>
</div>
<p></p>
<div class="field">
<%= label_tag :password %><br/>
class SessionsController < ApplicationController
def new
if member = Member.find_by_password_digest(cookies[:digest])
session[:member_id] = member.id
redirect_to (session[:ref] || root_path), :notice => "Welcome back #{member.first_name}"
end
end
def create
class ApplicationController < ActionController::Base
protect_from_forgery
def current_ability
@current_ability ||= Ability.new(current_member)
end
rescue_from CanCan::AccessDenied do |exception|
flash[:alert] = "Access Denied."
redirect_to root_url