This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
2007-11-15 19:16:52 -05:00
|
|
|
##
|
|
|
|
# This model will represent a beverage produced by a Brewery.
|
|
|
|
#
|
|
|
|
class Beer < ActiveRecord::Base
|
|
|
|
belongs_to :brewery
|
2007-11-17 03:40:46 -05:00
|
|
|
has_one_tuxwiki_page :owner_class => 'Beer'
|
2008-01-07 00:46:43 -05:00
|
|
|
belongs_to :style
|
|
|
|
validates_presence_of :style_id
|
2008-01-31 23:46:06 -05:00
|
|
|
has_many_tagged_images
|
2007-11-15 19:16:52 -05:00
|
|
|
|
2007-11-15 22:11:50 -05:00
|
|
|
##
|
|
|
|
# Returns a list of attributes for the Page partial.
|
|
|
|
#
|
|
|
|
def page_attributes
|
|
|
|
pattr = []
|
2007-11-17 02:12:50 -05:00
|
|
|
unless brewery.nil?
|
|
|
|
pattr << "Brewery: #{brewery.title}"
|
|
|
|
end
|
2007-11-15 22:11:50 -05:00
|
|
|
pattr << "ABV: #{"%.1f" % abv}%" unless abv.to_s.empty?
|
|
|
|
unless original_gravity.to_s.empty?
|
|
|
|
pattr << "Original Gravity: #{original_gravity}"
|
|
|
|
end
|
|
|
|
unless final_gravity.to_s.empty?
|
|
|
|
pattr << "Final Gravity: #{final_gravity}"
|
|
|
|
end
|
2008-01-07 00:46:43 -05:00
|
|
|
pattr << "Style: #{style.title}"
|
2007-11-15 22:11:50 -05:00
|
|
|
pattr
|
|
|
|
end
|
2007-11-15 19:16:52 -05:00
|
|
|
end
|