Forum: Ruby on Rails RJS form validation

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Marcelo B. (Guest)
on 2008-12-28 23:16
(Received via mailing list)

I'm trying to add and validate objects using RJS.

I have a page where if a user clicks on a link a form partial is
inserted via javascript(depending on the click).

If that form is valid I would like to remove it and display the
object, otherwise rewrite the form with the errors inline(next to each

I'm stuck at the point where I don't know how to rewrite the form. On
the first insert the div with the form has no unique id(since a user
can click multiple times and insert multiple forms, and I need the
update the proper one).

My stupid idea is to generate a random number and pass that as an id
to the div form and via hidden_field so I know what to remove/update.

I'm sure there has to be a better way. I've been looking for tutorials
but I haven't found something specifically for what I want to do.

This topic is locked and can not be replied to.