How to auto submit a Rails form on a page visit

Viewed 2271

i have a form which i want to be auto submited when a page is visited maybe through jquery or any other means the reason why is that i want a create action to be triggered so i can make use it my table for the form is

class CreateWhatsups < ActiveRecord::Migration
  def change
    create_table :whatsups do |t|
      t.string :details, :default => "visited"
      t.integer :user_id


      t.timestamps
    end
  end
end

my form includes

<%= form_for(@whatsup) do |f| %>
  <div class="field">
    <%= f.label :details %><br>
    <%= f.text_field :details %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

how do i make this form auto submit when i place it anywhere in my rails application without clicking the submit button

2 Answers
Related