I want to bring a bug to the attention of the newsgroup that I haven’t
been able to track down. John has asked that I post this here in hopes
that one of you might be able to identify this issue and submit a patch.
In some cases Radiant is failing to provide validation error messages to
users. Instead of providing specific messages tied to the offending
fields, they only get the one error message across the top of the
screen. When that’s their only message it comes across like “Oops, you
goofed. Now let’s see if you’re smart enough to figure out where. Mwaa
haa haa haaa!” (well, ok different users read things differently).
Now, this doesn’t happen in every installation. I notice a relationship
depending on whether I’m running radiant via gem or with radiant
installed in my project’s /vendor directory (running from gem works
fine, installed in /vendor doesn’t). Please note: this is an
observation and a starting point but I haven’t proven anything so far.
By the way, the Radiant Demo (http://demo.radiantcms.org) is missing
these error messages.
My ticket is here: http://dev.radiantcms.org/radiant/ticket/601
-Chris
From what I’ve found out, the generic error messages you’re talking
about come from
Admin::AbstractModelController#announce_validation_errors (in
app/controllers/admin/abstract_model_controller.rb). Neither the
layout for all of the admin controllers or the individual templates
for any of the actions call the standard error_messages_* helpers,
which (unless I’m missing another better way to access them) would be
the best way to access the validation error messages and report them
in the view.
Looking through a couple of revisions, I haven’t actually found any
where the errors are reported that way, so I’m a bit at a loss for why
it would be working with the gem.
I can, however, verify that the demo site shows the
less-than-desirable behavior.
-Andrew
On Jan 18, 2008 12:01 AM, Chris P.
Alright, so I made a instance with the 0.6.4 gem and was able to
replicate that we used to get feedback. The thing is, the pertinent
view code is the same.
Which got me thinking that it might have something to do with Rails
2.0? Does anyone know if the error message handling was changed?
Another possible problem might be that the templates are not using the
form_for helper, and are instead just outputing form tags. Perhaps
there’s some magic state underneath it all that’s set by this tag?
I’ll look into this some more after lunch.
-Andrew
Ugh, now I can’t replicate with edge… I must have been mistaken.
And ignore what I said about Rails 2.0… looking in svn, I see that
the Rails 2.0 upgrade is in a different branch.
In any event, the only other thing I’d suggest to you Chris, is to
check your environment.rb and make sure it has something like this
(should be near the bottom):
ActionView::Base.field_error_proc = Proc.new do |html, instance|
%{
#{html} •
#{[instance.error_message].flatten.first}
}
end
-Andrew
Andrew O’Brien wrote:
%{
#{html} •
#{[instance.error_message].flatten.first}
}
end
-Andrew
Thanks for your hard work Andrew. I’ll take a look later this evening.
But it’s not me I’m concerned about – after all the RadiantCMS demo
site shows the same behavior. I’m concerned that this could be a
widespread bug – one that we wouldn’t hear about from our users because
they’d just think “this is frustrating - but that’s just the way it has
to be.” Something that goes against the design ethic of Radiant, I
think.
-Chris
Hi Chris,
Looks like that line was added in Changeset 576 (Nov 6, 2007):
http://dev.radiantcms.org/radiant/changeset/576#file8
If you generated your instance before that, that change won’t be
reflected.
-Andrew
On Jan 19, 2008 12:11 AM, Chris P.
Andrew O’Brien wrote:
%{
#{html} •
#{[instance.error_message].flatten.first}
}
end
-Andrew
Well, you may have hit on it Andrew. If I look at my project with
radiant installed in the /vendor directory, I see the code you mention
in:
/vendor/radiant/config/environment.rb
but not at:
/config/environment.rb
And adding the code to the /config/environment.rb seems to fix it. So
can anyone explain why these versions are different (and if it’s
actually a Radiant issue)? (Actually there are more differences in
these files than just this one but most of the others seem explainable).
And I might consider trying to write a patch but I don’t even know what
I’m trying to patch – a rake task maybe? Nor am I sure what kind of
testing that would require. Can anyone on core offer some insight here?
-Chris