I have this model:
class ThermoDetectorOrderLetter < ActiveRecord::Base
include ElementValidation
validates_presence_of :sales_name, :item_code, :design_type
protected
def validate
radio_button_with_single_text_field_validated(errors,
calibration_code_of_thermocouple, :calibration_code_of_thermocouple)
order_status_validated(errors, order_status, :order_status)
…
Other model have similar attributes:
class TubularHeaterOrderLetter < ActiveRecord::Base
include ElementValidation
validates_presence_of :sales_name, :item_code, :design_type
protected
def validate
radio_button_with_single_text_field_validated(errors,
calibration_code_of_thermocouple, :calibration_code_of_thermocouple)
order_status_validated(errors, order_status, :order_status)
…
This is ElementValidation file that is included by that two models.
module ElementValidation
class CommonValidation < ActiveRecord::Base
def CommonValidation.common_validation
validates_presence_of :sales_name
end
end
def order_status_validated(errors, order_status, order_status_symbol)
…
end
…
It works fine… However I try to remove validates_presences_of: line
from two model with this:
class ThermoDetectorOrderLetter < ActiveRecord::Base
include ElementValidation
…
def validate
CommonValidation.common_validation
radio_button_with_single_text_field_validated(errors,
calibration_code_of_thermocouple, :calibration_code_of_thermocouple)
…
But it said: uninitialized constant CommonValidation
Why is it not recognized? order_status_validated function that reside in
Module ElementValidation is recognized by model.
Thank you.