## publisher_controller.rb
class Admin::PublisherController < ApplicationController
def login
return unless request.post?
publisher = Publisher.find_by_name(params[:publisher][:name])
if publisher.password == params[:publisher][:password]
redirect_to :action => 'index'
else
flash.now[:notice] = "Please login!"
end
end
end

## Publisher.rb
# == Schema Information
# Schema version: 9
#
# Table name: publishers
#
# id :integer(11) not null, primary key
# name :string(255) default(""), not null
# email :string(255)
# secret :string(255)
#

# Require BCrypt library.
require 'bcrypt'

class Publisher < ActiveRecord::Base
include BCrypt

def password
@password ||= Password.new(secret)
end

def password=(new_password)
@password = Password.create(new_password)
self.secret = @password
end
end