Reputation: 203
I have this transaction:
begin
ActiveRecord::Base.transaction do
route_array.each do |r|
Rails.logger.info r.save
end
end
end
As you can see I have the route_array
and I'm trying to save it in the database, but r.save
returns false
and I have no clue why. Any idea?
Upvotes: 0
Views: 361
Reputation: 3371
The main raison is your model RouteArray has some validations which are not respected.
You can try this code :
ActiveRecord::Base.transaction do
route_array.each do |r|
if !r.valid?
Rails.logger.info r.errors.inspect
else
Rails.logger.info r.save
end
end
end
Upvotes: 2