I want submit a form via ajax only if i have a new record, so I've set:
(I'm using simple_form)

= simple_form_for @document, :html => { :multipart => true }, :remote
=> @document.new_record? ? true : false,  do |f|
  = render 'shared/error_messages', :object => @document

  = field_set_tag t('document') do
    .block
      .column.span-24
        .inputs
          = f.input :name
          = f.input :description
          = f.input :doc, :as => :file
          = f.input :company_id, :input_html => { :value =>
params[:company_id] }, :as => :hidden if @document.new_record?

    .actions
      = f.button :submit

It works if the validations are all ok but if a validation fails, I
correct the error and then submit again, remote is no longer valid
because, I think, new_record? return false.
Isn't it?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to