Topic: DRY form building with remote_form_for and form_for ??

Hi, I'd like to reuse the same code for building a form whether it's a
standard page, or an inline AJAX form.

Let's use the boolean variable is_ajax to set the environment type (ie if set to true, use remote_form_for; if false, form_for).

Something like this:

send(is_ajax ? "remote_form_for" : "form_for") (...) do |f|
  f.text_field ... etc
end

Anyone know how to do this?
Thanks

Zubin

Re: DRY form building with remote_form_for and form_for ??

A helper?

def same_form_for(object_name, *args, &proc)
  if is_ajax
    remote_form_for(object_name, args, proc)
  else
    form_for(object_name, args, proc)
  end
end

I'm not sure if this will work, but it's worth a shot.