Search code examples
ruby-on-railsrubyruby-on-rails-3.2ajaxform

Submitting Form Data which is already existed as object(rails3.22)


How can I submit a form with data taken using GET request from another object? Could anyone help on how to implement this with ajax and create a method in controller?


Solution

  • 1 => For GET request use method: :get

    2 => For Ajax submit use :remote => true

    <%= form_for @object, url: create_object_path, :remote => true, method: :get do |f| %>
      <%=f.text_field :field_1%>
      <%=f.text_field :field_2%>
      <%=f.text_field :field_3%>
      <%= f.hidden_field :another_field, :value @hpentry.HPEntry_Id.present? ? @hpentry.HPEntry_Id : nil%>
      <%=f.submit :submit%>
    <%end%>