Skip to content

Commit

Permalink
modified: app/models/permission.rb
Browse files Browse the repository at this point in the history
modified:   app/models/tag.rb
modified:   db/migrate/20121031055154_create_tags.rb
	-- fixed class label as attribute bug (my bad)
  • Loading branch information
atruskie committed Nov 2, 2012
1 parent 8caf246 commit e3f8767
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/models/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Permission < ActiveRecord::Base
# belongs_to :user

# enumerations
enumerize :level, :in => [:owner, :write, :read, :none], :default => :none, predicates: true
enumerize :level, :in => [:owner, :writer, :reader, :none], :default => :none, predicates: true


# validation
validates :level, :presence => true
Expand Down
19 changes: 9 additions & 10 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Tag < ActiveRecord::Base
has_many :audio_events, :through => :audio_event_tags

# attr
attr_accessible :class, :is_taxanomic, :text, :type_of_tag
attr_accessible :is_taxanomic, :text, :type_of_tag

# userstamp
stampable
Expand All @@ -15,21 +15,20 @@ class Tag < ActiveRecord::Base
validates_as_paranoid

# enums
enumerize :class, :in => [:looks_like, :sounds_like], predicates: true
enumerize :type_of_tag, :in => [:common_name, :species_name], predicates: true
enumerize :type_of_tag, :in => [:common_name, :species_name, :looks_like, :sounds_like], predicates: true

# validation
validates :is_taxanomic, :presence => true
validates :text, :uniqueness => { :case_sensitive => false }
validate :class_mutually_exclusive_with_tag_type
#validate :class_mutually_exclusive_with_tag_type

# custom validation
def class_mutually_exclusive_with_tag_type
return if self.class.nil? || self.type.nil?

errors.add(:class, "class and type_of_tag cannot both be set")
errors.add(:type_of_tag, "class and type_of_tag cannot both be set")
end
#def class_mutually_exclusive_with_tag_type
# return if self.class.nil? || self.type.nil?
#
# errors.add(:class, "class and type_of_tag cannot both be set")
# errors.add(:type_of_tag, "class and type_of_tag cannot both be set")
#end

private
# default values
Expand Down

0 comments on commit e3f8767

Please sign in to comment.