Customized User List
Added by Steven Fritzsche over 16 years ago
- bad english ***
I want to customize my user list in Administration -> Users... i have manual add a row in the table users with the name 'group' (like status row).
In the users_controller.rb there exists the following lines:
... @users = User.find :all,:order => sort_clause,
:conditions => conditions, ....
i changed it in:
... @users = User.find :all,:order => sort_clause,
:conditions => ["group = '1'"], ....
the result is :
... Mysql::Error: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group = '1') ORDER BY login asc LIMIT 0, 25' at line 1: SELECT * FROM `users` WHERE (group = '1') ORDER BY login asc LIMIT 0, 25 ...
when i use these:
... u d = User.find :all,:order => sort_clause,
:conditions => ["admin = '1'"], ....
or:
... u d = User.find :all,:order => sort_clause,
:conditions => ["firstname = 'steven'"], ....
it works fine.
pls help me
Replies (3)
RE: Customized User List - Added by Thomas Löber over 16 years ago
GROUP
is a reserved word in most SQL dialects. So you should not use it as a column name.
RE: Customized User List - Added by Thomas Löber over 16 years ago
I would like to add that in MySQL you may quote the column name if it is a reserved word:
:conditions => ["`group` = '1'"]