Displaying 1 result from an estimated 1 matches for "validate_field".
2006 Apr 11
1
Mixins?
...few of my model classes that I wanted to
push into a helper. Now I reckoned that the Ruby way was to create a module
and mix it in with include. However, I can''t get it to work <frustration>
In the first instance I put it straight into the models directory:
module FieldHelper
def validate_field
if template_field.mandatory? && (!field_value || field_value.length==0)
errors.add(template_field.name, _(''cant.be.blank''))
end
end
end
Now in the model I have this :
require "field_helper"
class SchemeAccountField < ActiveRecord::Base
inc...