From: Sathiyaraj Gurusamy Date: 2011-01-20T14:14:09+09:00 Subject: undefined method `before_create' for main:Object Hi, ruby=1.9.2 rails=3.0.1 I am developing simple user registration application using ruby on rails my model is require 'digest/sha2' class User < ActiveRecord::Base has_many :user_sessions, :order => "created_at DESC" has_many :sessions, :through => :user_sessions attr_accessor :password,:password_confirmation validates_uniqueness_of :username,:email_address,:mobile,:scope => "active" validates_confirmation_of :password, :on => :create, :message => "Passwords does not match"end before_create :hash_password private # Digests the password given and stores a unique salt and hash as a results def hash_password return if self.password.blank? self.password_salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp self.password_hash = generate_password_hash(self.password) unless self.password.blank? end def generate_password_hash(password) Digest::SHA256.hexdigest(password + self.password_salt) end controller def new if request.post? and params[:user] @user = User.new(params[:user]) if @user.save session[:user_id] = @user.id flash[:notice] = "User #{@user.username} created!" redirect_to :action => "index" end end end But when i try to registration i got below error "undefined method `before_create' for main:Object" Any help would be appreciate thanks and regards, sathiya_rails -- Posted via http://www.ruby-forum.com/.