Skip to content

Instantly share code, notes, and snippets.

Introduction
Who is This Book For?
10
How to Use This Book
11
Contacting the Author
11
Acknowledgements
12
Book Updates and Sharing
# so obviously a method named current_user_session
def current_user_session
# @current_user_session is an instance-level variable
# .defined? is a standard unary ruby predicate, returns nil if there is nothing with the specified name in scope, otherwise returns a string
# not really important what it returns because any string will evaluate as true
# so if something has already defined @current_user_session, we return it, which bails out of the method
return @current_user_session if defined?(@current_user_session)
# we'll only get here if @current_user_session isn't yet defined
# in which case we call the find class method of UserSession to get one
# and store it in the instance variable
def get_receipt_call(start_date, end_date, options = {})
options = {
:use_sell_date => false,
:per_page => 50,
:current_page => 1,
:paginate => false
}.merge(options)
request = build_receipt_request(start_date, end_date, options)
response = post_xml(request)
<div>
<div id="report_left">
<div class="reverse_fancy">
<h1>New <%= @category_type.capitalize %> Entry</h1>
</div>
<div class="clear"></div>
<div class="form_container">
<%= render :partial => 'form', :locals => {:mode => 'add'} %>
</div>
</div>