Permalink
Browse files

fix tag logic to not require persistence

  • Loading branch information...
1 parent 1455dae commit 64812a8ff54547db7e37e2201c6791fceb297493 Brent Vatne committed May 29, 2012
Showing with 8 additions and 12 deletions.
  1. +4 −6 lib/banyan/category.rb
  2. +4 −6 lib/banyan/category_group.rb
View
@@ -15,21 +15,19 @@ class Category < ActiveRecord::Base
acts_as_nested_set
- before_save :set_tag, :unless => :tag?
-
validates_presence_of :name
attr_accessible :name, :tag
translates :name
friendly_id :name, :use => :slugged
+ def tag
+ read_attribute(:tag) || name
+ end
+
private
def should_generate_new_friendly_id?
new_record? || slug.blank?
end
-
- def set_tag
- self.tag = name
- end
end
end
@@ -14,21 +14,19 @@ class CategoryGroup < ActiveRecord::Base
acts_as_nested_set
- before_save :set_tag, :unless => :tag?
-
attr_accessible :name, :tag
validates_presence_of :name
translates :name
friendly_id :name, :use => :slugged
+ def tag
+ read_attribute(:tag) || name
+ end
+
private
def should_generate_new_friendly_id?
new_record? || slug.blank?
end
-
- def set_tag
- self.tag = name
- end
end
end

0 comments on commit 64812a8

Please sign in to comment.