Class: ValidatableForm

Inherits:
Object
  • Object
show all
Includes:
Validatable
Defined in:
lib/validatable_form.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.form_fields(*form_fields) ⇒ Object



6
7
8
9
10
11
# File 'lib/validatable_form.rb', line 6

def self.form_fields(*form_fields)
  return if form_fields.empty?
  attr_accessor *form_fields # !> `*' interpreted as argument prefix
  initializations = form_fields.map { |field| "@#{field} = params[:#{field}]"}.join("\n")
  module_eval "def initialize(params={})\n return unless params\n #{initializations}\n end"
end

Instance Method Details

#idObject

used by some of the Rails view helpers like form_for



14
15
16
# File 'lib/validatable_form.rb', line 14

def id
  nil
end

#new_record?Boolean

used by some of the Rails view helpers like form_for

Returns:

  • (Boolean)


19
20
21
# File 'lib/validatable_form.rb', line 19

def new_record?
  true
end