Please solve my rails problem

What's happening now? Does it never find the previous login?
Is date a Date or a Time? If the database has it as a datetime then Date.today isn't going to match it.

Is your date column a date or a datetime?

Now I see it. You are mixing attandance and @attandance, which are not the same variable.

(By the way, not that it matters here, but it's attendance, with an e.)

You just have to be consistent.

If you do attendance = Find...

then you have to do

if attendance, not if @attendance.

def login
    session[:user_id] = nil
    if request.post?
      user = User.authenticate(params[:name], params[:password])
      if user
        session[:user_id] = user.id
        if user.user_type=='admin'
          redirect_to :controller
=>'admin_information',:action=>'emp_list'
        elsif(user.user_type=='user')

         p "-------------finding in db-----------------"
          attandance = Attandance.find(:first, :conditions=>['name=?
and date=?',user.name,Date.today])
          if attandance
            flash[:notice]="Already entered"

redirect_to :controller=>'information', :action=>'emp_list'
            else
              time_in = Time.now
            if time_in.hour > 10 and time_in.min > 10

              attandance =
Attandance.create(:time_in=>Time.now,:name=>user.name,:present=>'late',:date=>Date.today,:information_id=>@information_id)
            else
              attandance =
Attandance.create(:time_in=>Time.now,:name=>user.name,:present=>'Yes',:date=>Date.today,:information_id=>@information_id)
            end

          #if @attandance.name==user.name and
@attandance.present=='yes'

          #attandance = Attandance.find(:first, :conditions=>['name=?
and date=?',user.name, Date.today])
          # if @attandance
          #flash[:notice]="Already entered"
          #else
          p "------#{@information_id}-----------"
          #attandance =
Attandance.create(:time_in=>Time.now,:name=>user.name, :present=>'Yes',:date=>Date.today,:information_id=>@information_id)
          #@people = Person.find_recent
          # @attandance = Attandance.time_in
          #end
          flash[:notice]="Your attandance is marked"
          redirect_to :controller =>'information',:action=>'emp_list'
        end
end
        #redirect_to :controller=>"admin_information", :action =>
"emp_list"
      else
        p"---------no msg-------------"
        flash[:notice] = "Invalid user/password combination"
      end
    end
  end

changed
          if @attandance
To
          if attandance.

Suggestion:
Better to move logic of late coming into corresponding model. (write
UT's)

Note:
If you are not sure when to use @attendance and attendance, please
read Ruby book OR Ask some one.

Thanks,

Regards,
Raghu Kumar K