Module: Permalink::ActiveRecord::ClassMethods
- Defined in:
- lib/permalink/active_record.rb
Instance Method Summary collapse
-
#permalink(from_column, options = {}) ⇒ Object
permalink :title permalink :title, :to => :custom_permalink_field permalink :title, :to => :permalink, :to_param => [:id, :permalink] permalink :title, :unique => true.
Instance Method Details
#permalink(from_column, options = {}) ⇒ Object
permalink :title permalink :title, :to => :custom_permalink_field permalink :title, :to => :permalink, :to_param => [:id, :permalink] permalink :title, :unique => true
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/permalink/active_record.rb', line 14 def permalink(from_column, = {}) include InstanceMethods .reverse_merge!({ to_param: [:id, :permalink], to: :permalink, unique: false, force: false }) self. = { from_column_name: from_column, to_column_name: [:to], to_param: [[:to_param]].flatten, unique: [:unique], force: [:force], scope: [:scope] } before_validation :create_permalink before_save :create_permalink end |