Module: Parameterize

Defined in:
lib/parameterize.rb,
lib/parameterize/version.rb

Defined Under Namespace

Modules: InstanceMethods

Constant Summary collapse

VERSION =
'0.3.0'

Instance Method Summary collapse

Instance Method Details

#parameterize(source = :title, options = {}) ⇒ Object

Adds a before validation filter for updating the param field with the parameterized version of the given source field.

Parameters:

  • source (Symbol, String) (defaults to: :title)

    The field to parameterize



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/parameterize.rb', line 9

def parameterize(source = :title, options = {})
  include InstanceMethods

  class_attribute :parameterize_config, :instance_writer => false
  before_validation :parameterize, :if => :parameterize?

  self.parameterize_config = {
    :source => source,
    :target => :param,
    :update => false
  }.merge(options)
end