32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/models/dhatu/testimonial.rb', line 32
def self.save_row_data(hsh)
error_object = Kuppayam::Importer::ErrorHash.new
return error_object if hsh[:name].to_s.strip.blank?
testimonial = Dhatu::Testimonial.find_by_name(hsh[:name].to_s.strip) || Dhatu::Testimonial.new
testimonial.name = hsh[:name].to_s.strip
testimonial.designation = hsh[:designation].to_s.strip
testimonial.organisation = hsh[:organisation].to_s.strip
testimonial.statement = hsh[:statement].to_s.strip
testimonial.status = hsh[:status].to_s.strip || PUBLISHED
testimonial.featured = hsh[:featured].to_s.strip || true
testimonial.priority = hsh[:priority].to_s.strip || 1
if testimonial.valid?
begin
testimonial.save!
rescue Exception => e
summary = "uncaught #{e} exception while handling connection: #{e.message}"
details = "Stack trace: #{e.backtrace.map {|l| " #{l}\n"}.join}"
error_object.errors << { summary: summary, details: details }
end
else
summary = "Error while saving testimonial: #{testimonial.name}"
details = "Error! #{testimonial.errors.full_messages.to_sentence}"
error_object.errors << { summary: summary, details: details }
end
return error_object
end
|