title: How to send data from Matlab to Rails
body: <p>I'm very new to Rails and web development. </p>
  
  <p>I'm generating a bunch of objects in Matlab and I'd like send these objects to a database in my Rails app.  Can anyone advise me on how to do this?</p>
  
  <p>So far, on the Rails end, I've generated basic scaffolding for my data. I can add objects to my database using a form at '/myobjects/new'.</p>
  
  <p>On the Matlab end, I've been trying to add objects using HTTP POST requests, like so:</p>
  
  <pre><code>s = urlread('http://localhost:3000/myobjects.json','POST',{'myobject','{name1:''value1''}'})
  </code></pre>
  
  <p>This fails and prints the following to the Rails console:</p>
  
  <pre><code>Started POST "/myobjects.json" for 127.0.0.1 at 2012-06-16 11:48:28 -0400
  Processing by MyobjectsController#create as JSON
    Parameters: {"myobject"=&gt;"{name1:'value1'}"}
  WARNING: Can't verify CSRF token authenticity
  Completed 500 Internal Server Error in 1ms
  
  NoMethodError (undefined method `stringify_keys' for "{name1:'value1'}":String):
    app/controllers/myobjects_controller.rb:43:in `new'
    app/controllers/myobjects_controller.rb:43:in `create'
  </code></pre>
  
  <p>This approach might be way off base, but hopefully the code above makes my goal clear.  Can anyone tell me how to fix my code, or suggest a better strategy for getting my data into rails?</p>
  
  <p>EDIT</p>
  
  <p>At the moment my new and create methods look like this (but I can change them as required)</p>
  
  <pre><code># GET /irs/new
    # GET /irs/new.json
    def new
      @ir = Ir.new
  
      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @ir }
      end
    end
  
    # POST /irs
    # POST /irs.json
    def create
      @ir = Ir.new(params[:ir])
  
      respond_to do |format|
        if @ir.save
         format.html { redirect_to @ir, notice: 'Ir was successfully created.' }
         format.json { render json: @ir, status: :created, location: @ir }
        else
          format.html { render action: "new" }
          format.json { render json: @ir.errors, status: :unprocessable_entity }
        end
      end
    end
  </code></pre>