Chapter 7 includes an example of using
Markaby. Of course, you may find that entering HTML directly in your code is easier to understand.
The single variable you pass to your view is an array of users. You pass it to your
eruby_object variable, and it becomes a class variable @users for your view, in the same
way that Rails views work.
The users variable is created by using the User.find method to loop through all of
your users. You add a not is_admin condition, which means that only non-admin users
will be included in your report. (This is assuming that admin users are used to administrate
the system and not to do sales work; if that??™s not true, you can easily remove this
condition.) The order is set through the option :order=>'last_name ASC, first_name ASC',
which means that you sort first by the last name, and second by the first name, both in
alphabetic, A??“Z order. The second sort order kicks in only if two people have the same
last name. If you replaced ASC with DESC, it would sort in Z??“A order.
Let??™s take a look at the actual view (Listing 8-3):
Salesperson Reward Report