I am trying to update an integer value on a table using Rails, but it
complains that I am violating a not-null constraint because I didn't
specify other attributes. My code is as follows:
I am trying to update an integer value on a table using Rails, but it
complains that I am violating a not-null constraint because I didn't
specify other attributes. My code is as follows:
or check out the find_or_create_by_* methods (or even find_or_initialize_by_*) if you might have a record, but are sure you will have one by the time the call is finished.
sup = Supplier.find_or_initialize_by_name("Supplier One") do |s|
s.num_products = total_products
# .. other changes
end