So here is my non-database model.
class UserApplication::CoApplicant
include ActiveModel::Validations
include ActiveModel::Conversion
attr_accessor :applicant, :first_name, :last_name, :email
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}", value)
end
end
def persisted?
false
end
end
I am looking to pass in an array of objects, that look something like this.
"applicant"=>{"0"=>{"email"=>"[email protected]", "last_name"=>"Jackson", "first_name"=>"Shaun"}, "1"=>{"email"=>"[email protected]", "last_name"=>"Davis", "first_name"=>"Dave"}}
The issue I am having is coming up with a way to validate each object. These values are
coming from a dynamically generated table, that can range from 1 - 10 rows.
"0" and "1" - Represents the table row. And I am looking to validate each set
of attributes { email, first_name, last_name}.
I have never had to do this type of validation before, so any help would be appreciated!