I am new to ROR and learning it. In my controller I have an admins
record and I am passing that admin object to the admin's view page to
get the name of the admin. But when I try to access the name it is
showing error as "undefined method `name' for :current_admin:Symbol"..
Please help..
Please find my code below
Sessions Controller
def create
admin=Admin.find_by_email(params[:session][:email].downcase)
if admin && admin.authenticate(params[:session][:password])
redirect_to(admins_index_path(:current_admin=>admin))
end
end
I tried with the the below code. But still getting the same result in
view page as "undefined method `name' for nil:NilClass"
def create
@admin=Admin.find_by_email(params[:session][:email].downcase)
user=User.find_by_email(params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
redirect_to(dashboard_path(:user=>user))
else
redirect_to(admins_index_path(:current_admin=>@admin))
end
end