> Markus wrote:
>> If Nick is correct that this blank report doesn't pass validation,
>> where exactly does the problem arise? Would having the rescue return
>> nil (and adding a "report_is_present" validation) suffice? This
>> assumes on the validations being ordered, which I'm not enough of a
>> rails nerd to know the practicality of.
>>
Nick wrote:
> Unfortunately, this actually causes bigger problems, because the report
> method is an override. From what I can surmise from experimentation, if it
> returns nil, rails assumes you want it to fall back to the default method,
> which then fails with the same error we deliberately rescued in our
> overridden version. This has the additional effect of also failing every
> time an invalid report is used, not just when they're created.
Ah yes, the infamous "Too Much Magic" error. It's good to see rails
still has it's hearts in the right places.
So what about having the rescue return the exception object and
watching for that? Or forgetting about the rescue entirely and having
a report_must_be_valid validation that 1) runs before any others
(again assuming the validations can be reliably ordered) and 2)
catches the exception and converts it to a failure, something like:
def report_must_be_valid
report rescue false
end
or
def report_must_be_valid
(report.is_a? Puppet::Transaction::Report) rescue false
end
or some such?
-- Markus
-----------------------------------------------------------
The power of accurate observation is
commonly called cynicism by those
who have not got it. ~George Bernard Shaw
------------------------------------------------------------
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.