title: Basic .ajax post to a rails 3.2.2 scaffold generating "WARNING: Can't verify CSRF token authenticity"
body: <p>I am trying to learn how to post some data using $.ajax through jquery to a simple rails scaffold project.  There is one standard scaffold created controller => Images </p>
  
  <pre><code>class ImagesController &lt; ApplicationController
    # GET /images
    # GET /images.json
    def index
      @images = Image.all
  
      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @images }
      end
    end
  
    # GET /images/1
    # GET /images/1.json 
    def show
      @image = Image.find(params[:id])
  
      respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @image }
      end
    end
  
    # GET /images/new
    # GET /images/new.json
    def new
      @image = Image.new
  
      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @image }
      end
    end
  
    # GET /images/1/edit
    def edit
      @image = Image.find(params[:id])
    end
  
    # POST /images
    # POST /images.json
    def create
      @image = Image.new(params[:image])
  
      respond_to do |format|
        if @image.save
          format.html { redirect_to @image, notice: 'Image was successfully created.' }
          format.json { render json: @image, status: :created, location: @image }
        else
          format.html { render action: "new" }
          format.json { render json: @image.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PUT /images/1
    # PUT /images/1.json
    def update
      @image = Image.find(params[:id])
  
      respond_to do |format|
        if @image.update_attributes(params[:image])
          format.html { redirect_to @image, notice: 'Image was successfully updated.' }
          format.json { head :no_content }
        else
          format.html { render action: "edit" }
          format.json { render json: @image.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /images/1
    # DELETE /images/1.json
    def destroy
      @image = Image.find(params[:id])
      @image.destroy
  
      respond_to do |format|
        format.html { redirect_to images_url }
        format.json { head :no_content }
      end
    end
  end
  </code></pre>
  
  <p>with one route => resources :images.  The database schema consists of one field => t.string :name.
  My initial test html file is:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"&gt;    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script&gt;
      $(document).ready(function(){
          $.ajax({
              type: 'POST', url: "localhost:3000/images",
              data: { name: "johngalt" }
          });
      });
      &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>The result from webrick is:</p>
  
  <pre><code>Started POST "/images" for 127.0.0.1 at 2012-04-17 09:50:19 -0500
  Processing by ImagesController#create as */*
    Parameters: {"name"=&gt;"johngalt"}
  WARNING: Can't verify CSRF token authenticity
     (0.1ms)  begin transaction
     SQL (63.5ms)  INSERT INTO "images" ("created_at", "name", "updated_at") VALUES (?, ?,  ?)  [["created_at", Tue, 17 Apr 2012 14:50:21 UTC +00:00], ["name", nil], ["updated_at",  Tue, 17 Apr 2012 14:50:21 UTC +00:00]]
     (2.0ms)  commit transaction
   Redirected to http://localhost:3000/images/7
   Completed 302 Found in 81ms (ActiveRecord: 65.6ms)
  </code></pre>
  
  <p>I'm not sure why name doesn't contain "johngalt".  Does this have something to do with the " WARNING: Can't verify CSRF token authenticity"?</p>
  
  <p><em><strong>Edit</em></strong>
  When I use curl:</p>
  
  <pre><code>curl -d "image[name]=johngalt"  localhost:3000/images.json
  </code></pre>
  
  <p>The record is created and the name field contains "johngalt".  In essence, I'm trying to figure out the .ajax equivalent of doing what I was able to do in curl?</p>