Prev | Current Page 222 | Next

David Berube

"Practical Reporting with Ruby and Rails"


path_to_html2ps = '/some/path/to/html2ps' #Insert your path to html2ps here.
The paths for ps2pdf and html2ps vary depending on your operating system.
Next, you create the Active Record models that represent the tables you??™re using:
class User < ActiveRecord::Base
has_many :meetings, :foreign_key=>:assigned_user_id
def reward
Reward.find(:first,
:conditions=>['meeting_count < ? ',
self.meetings.count],
:order=>'meeting_count DESC',
:limit=>1)
end
end
class Meeting < ActiveRecord::Base
belongs_to :users, :foreign_key=>:assigned_user_id
end
class Reward < ActiveRecord::Base
end
CHAPTER 8 n CREATING SALES PERFORMANCE REPORTS WITH SUGARCRM 162
You create the models by deriving from ActiveRecord::Base (as discussed in Chapter 1).
The User model also has a custom method, reward, which returns a reward object??”one
whose meeting count is lower than the number of meetings a salesperson has. Note,
though, that the possible rewards are sorted by a descending meeting_count; in other
words, the first reward listed, and thus the reward returned, will be the reward with the
highest meeting_count field.


Pages:
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
pożyczki tłumaczenia rosyjski warszawa 2 1 Paula Abdul nieruchomości szczecin