L.S.,
I have created a rails application which works, I now want to write a
little batch program which uses the different “models” to perform some
tasks. This is what I do:
#!/usr/bin/env ruby
require File.dirname(FILE) + ‘/…/config/environment’
require ‘system’
s = System.new( :name => ‘a’)
if s.save == false
print “Error saving\n”
exit
end
System is a model, has a field “name” which is unique.
class System < ActiveRecord::Base
validates_uniqueness_of :name
end
When I run the program the second time, I get the “Error saving”
message and the program exits (as expected).
There is no error raised by the save function. If I do no explicit
test, the program just runs on. Is there a way to get better error
handling?
Gr.
Robert