Dear all
I encounter error when I login my Web application
NoMethodError in AdminController#login
undefined method `get_title'' for #<Class:0x63ac78>
Here is part of my code
controller/admin_controller.rb
def login
session[:user_id] = nil
if request.post?
if User.authenticate(params[:name], params[:password])
user = User.find_by_name(params[:name])
if !user
user = User.new
user.name = params[:name]
user.title = User.get_title #I think this trigger the error
user.save
end
session[:user_id] = params[:name]
redirect_to(:controller => ''ecpath_app_version'',
:action =>
''index'')
else
#flash[:notice] = "Invalid user/password combination"
end
end
end
Here is my user model
model/user.rb
require ''net/ldap''
class User < ActiveRecord::Base
set_table_name "users"
attr_accessor :title
def self.authenticate(username,password)
treebase = "dc=corp,dc=ha,dc=org,dc=hk"
filter = Net::LDAP::Filter.eq( "sAMAccountName", username )
login_succeeded = false
ldap_con = initialize_ldap_con(username,password)
if ldap_con.bind
login_succeeded = true
@title=ldap_con.search( :base => treebase, :filter => filter,
:attributes => ''displayname'').first.displayname.to_s
end
login_succeeded
end
# I have define the get_title here..
def get_title
return @title
end
My users table schema
name varchar(20)
created_at datetime
updated_at dataetime
title varchar(30)
Please give me some advices. Thank you.
Valentino
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---