Therefore, the naming rules described in
the previous section, which come as a result of using the :include option, apply to the columns
specified in the :order parameter as well.
:select
You can use the :select option to specify some extra columns in the SELECT clause. Any extra
columns will be added as additional attributes on the returned objects. However, because
Active Record doesn??™t know how to save these extra attributes, the objects it returns will automatically
be marked as read only, so they cannot be saved.
The :select option is most often used together with the :group or :joins options, both of
which are described in the following subsections. For now, let??™s do something simple and add
an extra string to our returned objects, as shown in the following SQL statement:
SELECT accounts.*, "extra data" FROM accounts
The Active Record equivalent would be
Account.find "all", :select => "accounts.*, 'extra data'"
:group
Much like the :order option described earlier, what you specify in the :group option directly
translates to a portion of the SQL query to be performed.
Pages:
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111