Permalink
Browse files

add :unique => false option for permalinks

  • Loading branch information...
technoweenie committed Sep 4, 2008
1 parent d633ed4 commit 162a7d9c7969cc3c5a45e988e5c4d553bb2e9ee0
Showing with 9 additions and 1 deletion.
  1. +4 −0 lib/permalink_fu.rb
  2. +5 −1 test/permalink_fu_test.rb
View
@@ -73,11 +73,15 @@ class << base
attr_accessor :permalink_field
end
base.send :include, InstanceMethods
+ base.alias_method_chain(:define_attribute_methods, :permalinks)
end
protected
def setup_permalink_fu
before_validation :create_unique_permalink if permalink_options[:unique]
+ end
+
+ def define_attribute_methods_with_permalinks
evaluate_attribute_method permalink_field, "def #{self.permalink_field}=(new_value);write_attribute(:#{self.permalink_field}, PermalinkFu.escape(new_value));end", "#{self.permalink_field}="
end
end
@@ -31,7 +31,11 @@ def self.primary_key
def self.logger
nil
end
-
+
+ def define_attribute_methods
+
+ end
+
# ripped from AR
def self.evaluate_attribute_method(attr_name, method_definition, method_name=attr_name)

0 comments on commit 162a7d9

Please sign in to comment.