Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8112159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:23:14+00:00 2026-06-06T02:23:14+00:00

I’m very new to Rails and web development. I’m generating a bunch of objects

  • 0

I’m very new to Rails and web development.

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?

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’.

On the Matlab end, I’ve been trying to add objects using HTTP POST requests, like so:

s = urlread('http://localhost:3000/myobjects.json','POST',{'myobject','{name1:''value1''}'})

This fails and prints the following to the Rails console:

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"=>"{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'

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?

EDIT

At the moment my new and create methods look like this (but I can change them as required)

# 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:23:18+00:00Added an answer on June 6, 2026 at 2:23 am

    In the end I gave up trying to do this with matlab’s built-in functions. Instead, I imported a Java library (Apache HttpComponents). Here’s the script I came up with. This did the job.

    javaaddpath(['utils/httpcomponents-client-4.2/lib/httpcore-4.2.jar']);
    javaaddpath(['utils/httpcomponents-client-4.2/lib/httpclient-4.2.jar']);
    
    
    import org.apache.http.impl.client.DefaultHttpClient
    import org.apache.http.client.methods.HttpPost
    import org.apache.http.entity.StringEntity
    
    
    httpclient = DefaultHttpClient();
    
    httppost = HttpPost('http://127.0.0.1:3000/myobjects.json');
    httppost.addHeader('Content-Type','application/json');
    httppost.addHeader('Accept','application/json');
    
    params = StringEntity('{"field1":"value1"}');
    httppost.setEntity(params);
    
    response = httpclient.execute(httppost);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.