This file contains hidden or 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 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 |
This file contains hidden or 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 | |
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 |
This file contains hidden or 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
<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/> |
This file contains hidden or 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
#!/usr/bin/env ruby | |
# This script parses US mailing addresses. | |
# | |
# For development, execute this from the command line to run the test cases. | |
# | |
# For production, just require the file, then: | |
# address_hash = AddressParser.new.parse(input_string) | |
require 'rubygems' |
This file contains hidden or 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
#!/usr/bin/env ruby | |
# This script parses US mailing addresses. | |
# | |
# For development, execute this from the command line to run the test cases. | |
# | |
# For production, just require the file, then: | |
# address_hash = AddressParser.new.parse(input_string) | |
require 'rubygems' |
This file contains hidden or 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 'rubygems' | |
require 'parslet' | |
class Address < Parslet::Parser | |
# Single character rules | |
rule(:comma) { str(',') >> space? } | |
rule(:space) { match('\s').repeat } | |
rule(:space?) { space.maybe } | |
rule(:newline) { str("\n").repeat } | |
rule(:digit) { match('[0-9]') } |
This file contains hidden or 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 'rubygems' | |
require 'parslet' | |
class Address < Parslet::Parser | |
# Single character rules | |
rule(:comma) { str(',') >> space? } | |
rule(:space) { match('\s').repeat } | |
rule(:space?) { space.maybe } | |
rule(:newline) { str("\n").repeat } | |
rule(:digit) { match('[0-9]') } |
This file contains hidden or 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 'rubygems' | |
require 'parslet' | |
class Address < Parslet::Parser | |
# Single character rules | |
rule(:comma) { str(',') >> space? } | |
rule(:space) { match('\s').repeat } | |
rule(:space?) { space.maybe } | |
rule(:newline) { str("\n").repeat } | |
rule(:digit) { match('[0-9]') } |
This file contains hidden or 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 User do | |
describe "Object Attributes" do | |
before(:each) { @obj = User.new } | |
specify { @obj.should respond_to(:first_name) } | |
specify { @obj.should respond_to(:last_name) } | |
specify { @obj.should respond_to(:login) } | |
end |
This file contains hidden or 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 User < ActiveRecord::Base | |
# ----- Devise ----- | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :confirmable, :lockable and :timeoutable | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable #, :validatable | |
# Setup accessible (or protected) attributes for your model | |
attr_accessible :email, :password, :password_confirmation, :remember_me |