lib/beerdb/models/brand.rb in beerdb-0.9.2 vs lib/beerdb/models/brand.rb in beerdb-0.9.3

- old
+ new

@@ -1,8 +1,9 @@ # encoding: UTF-8 -module BeerDb::Model +module BeerDb + module Model class Brand < ActiveRecord::Base # NB: use extend - is_<type>? become class methods e.g. self.is_<type>? extend TextUtils::ValueHelper # e.g. self.find_key_n_title, self.is_year?, self.is_region?, is_address?, is_taglist? etc. @@ -13,11 +14,11 @@ belongs_to :brewery, :class_name => 'BeerDb::Model::Brewery', :foreign_key => 'brewery_id' has_many :beers, :class_name => 'BeerDb::Model::Beer', :foreign_key => 'brand_id' - validates :key, :format => { :with => /^[a-z][a-z0-9]+$/, :message => 'expected two or more lowercase letters a-z or 0-9 digits' } + validates :key, :format => { :with => /\A[a-z][a-z0-9]+\z/, :message => 'expected two or more lowercase letters a-z or 0-9 digits' } def self.create_or_update_from_values( values, more_attribs = {} ) attribs, more_values = find_key_n_title( values ) attribs = attribs.merge( more_attribs ) @@ -55,6 +56,7 @@ rec.update_attributes!( attribs ) end end # class Brand -end # module BeerDb::Model + end # module Model +end # module BeerDb