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 permalink :title, separator: “_” permalink :title, normalizations: array_of_normalizations.
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 permalink :title, separator: “_” permalink :title, normalizations: array_of_normalizations
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/permalink/active_record.rb', line 16 def permalink(from_column, = {}) include InstanceMethods = .reverse_merge({ to_param: [:id, :permalink], to: :permalink, unique: false, force: false, separator: "-", normalizations: Permalink::DEFAULT_NORMALIZATIONS }) self. = { from_column_name: from_column, to_column_name: [:to], to_param: [[:to_param]].flatten, unique: [:unique], force: [:force], scope: [:scope], separator: [:separator], normalizations: [:normalizations] } before_validation :create_permalink before_save :create_permalink end |