I want to have a method in my controllers defined that returns the count of records in a users database. Is this the correct syntax? What am I doing wrong. I seem to get an error.
def users
@users = User.find(:all)
sql = ActiveRecord::Base.connection();
sql.execute "SET autocommit=0";
sql.begin_db_transaction
id, value =sql.execute("SELECT COUNT(*) as "Number of Users" FROM users;").fetch_row;
sql.commit_db_transaction
@count=value;
end
2007-12-10
05:41:08
·
1 answers
·
asked by
theedge2343
2
in
Computers & Internet
➔ Programming & Design