Module: Parameterize

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

Defined Under Namespace

Modules: InstanceMethods Classes: Railtie

Constant Summary collapse

VERSION =
'0.1.2'

Instance Method Summary collapse

Instance Method Details

#parameterize(source = :title) ⇒ 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
# File 'lib/parameterize.rb', line 9

def parameterize(source = :title)
  include InstanceMethods
  
  class_attribute   :param_source_field
  before_validation :update_param
  
  self.param_source_field = source
end