Skip to content

Instantly share code, notes, and snippets.

@cypok
Created January 25, 2009 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cypok/52485 to your computer and use it in GitHub Desktop.
Save cypok/52485 to your computer and use it in GitHub Desktop.
module Authlogic
module Session
# = ActiveRecord Trickery
#
# Authlogic looks like ActiveRecord, sounds like ActiveRecord, but its not ActiveRecord. That's the goal here. This is useful for the various rails helper methods such as form_for, error_messages_for, or any
# method that expects an ActiveRecord object. The point is to disguise the object as an ActiveRecord object so we have no problems.
module ActiveRecordTrickery
def self.included(klass) # :nodoc:
klass.extend ClassMethods
klass.send(:include, InstanceMethods)
end
module ClassMethods # :nodoc:
# this method was added
def human_name(*args)
klass.human_name(*args)
end
def human_attribute_name(*args)
klass.human_attribute_name(*args)
end
end
module InstanceMethods # :nodoc:
def new_record?
new_session?
end
end
end
end
end
class UserSession < Authlogic::Session::Base
acts_as_translatable_model
login_blank_message "не должен быть пустым"
login_not_found_message "не найден"
password_blank_message "не должен быть пустым"
password_invalid_message "неверный"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment