Hi Ryan, thanks for this (and all) screencast. About this one, where can we find the reference of ActionView? I think this documentation will be usefull for rewrite the functions.
Regards.
very useful for me!
thanks!
Already used that :).
"<span class=\"fieldWithErrors\">#{html_tag}</span>"
Thanks anyway.
Hmm... What if I don't want another wrapping tag but just want to set the class attribute of the input field, then how would I do?
Nice job!
I know you get tons of requests for screencasts but I'd actually like to see something small about Rake. Obviously you couldn't cover all of Rake in 3-4 minutes, but it might be instructive to see a small task or two that you've written that find yourself using frequently.
Thanks here too. I"ve wasted a lot of time trying to make my forms look good when errors are displayed, this allows me to get rid of a bunch of hacky code.
These RailsCasts are so great - I am speechless! A BIG THANK YOU!
Greeting from Germany,
Martin
@Martin, I don't know if this feature is documented in the rails api. I haven't seen it anyway.
@Erik, there's a snippet on this page which does that:
http://snippets.dzone.com/tag/field_error_proc
I think it would be cleaner to change an option in instance_tag and have it regenerate the HTML. You just have to watch out for the seamless loop because regenerating the HTML calls the proc again.
@Jim, good suggestion. An episode about Rake is planned, just need to sit down and record it some day. :)
Ryan,
You rock. I have been a big fan of yours through both your amazing posts at railsforum.com and these railscasts.
Keep up the good work. All the best.
Usefull tutorial. I haven't commented any screencasts on this page before but I've seen all of them - thanks! You're doing great job for rails community :)
I am just wondering if there is a way to wrap the error that corresponds to the input control within the span block. It is always nicer to allow the user to see the error message right beside the input control rather than a summary of all the errors at the top of the page.
Thanks for the videos, I always look forward to them.
@Chris, I beleive this is possible through instance_tag. You can access the model through that in addition to the errors and the name of the attribute the field represents. The pieces are all there, you just have to figure out how to put them together.
Unfortunately instance_tag (ActionView::Helpers::InstanceTag) is poorly documented. You have to read the source code.
Hi Ryan, thanks for this new screencast. About this error validation tips, I have one question. Sometimes when I manualy add an error action in a validation method in the model, nothing happend on the field.
IE:
def validate
if a_special_check
errors.add("field_name", "my message...")
return false
end
Any idea ?
Hmm, if the field name you provide matches the name used in the field itself, it should work. You might want to try making it a symbol.
errors.add(:field_name, ...)
Thanks Ryan. I wanted to learn how to do that just a few days ago and this railscast will save me a lot of time!
I'm a big fan and would not miss an episode! Keep up the great job.
Thanks.
It would be great to show an example of how to mark an associated label with an asterisk or something similar. I think this is used a lot to mark a field as "required" i.e. instead of having a red border around the field, you would mark the label shown above the field either in read or with an red asterisk.
How would I do that?
Hi Ryan,
As you tell me, I try to use :field_name instead of "field_name", but dont work... Moreover, this feature dont work only with id fields. Fo you have another idea ?
Thanks
@Olivier, hmm I'm not sure what the problem is without seeing more code. But here is not the best place to post the code. Instead I recommend starting a thread over at railsforum.com with a detailed explenation of your problem. I frequently visit that forum so I'll probably be able to reply there. Thanks. :)
I have always wanted to know this. Extremely helpful!Thanks also for your contributions over at railsforum.com!
It seems to me, that in rails 2.0.2 the code doesn't work. Restarting my mongrel server I get several errors ...
My fault, the code has to be at the very end of environment.rb -- sorry
Because of the relation between the architectonic of pure reason and the things in themselves, it remains a mystery why our judgements prove the validity of the empirical objects in space and time; for these reasons, metaphysics, insomuch as philosophy relies on our faculties, can never furnish a true and demonstrated science, because, like the Ideal of practical reason, it is what first gives rise to analytic principles.



