Note that there are some explanatory texts on larger screens.

plurals
  1. POASIFormDataRequest to send post data to server rails, but in the insert have a null value
    text
    copied!<p>I'm using ASIFormDataRequest to send multipart POST data to a server rails.</p> <p>The code snippet where I set the value with a text field and than send POST is below:</p> <pre class="lang-c prettyprint-override"><code>NSURL *url = [NSURL URLWithString:@"http://localhost:3000/users"]; ASIFormDataRequest *requestMsg = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; [requestMsg setDelegate:self]; [requestMsg setPostValue:labelName.text forKey:@"name"]; [requestMsg startSynchronous]; </code></pre> <p>In my rails log console I don't have any error and the post started correctly. </p> <p>The problem is in the INSERT where the value of "name" is NULL:</p> <pre><code>Started POST "/users" Parameters: {"name"=&gt;"john"} INSERT INTO "users" ("name", "created_at", "updated_at") VALUES (NULL, '2011-06-08 11:38:55.936498', '2011-06-08 11:38:55.936498') </code></pre> <p>Has anyone had this problem before?</p> <p>This is the server side code</p> <pre class="lang-rb prettyprint-override"><code>class UsersController &lt; ApplicationController # GET /users/new def new @user = User.new respond_to do |format| format.html # new.html.erb format.xml { render :xml =&gt; @user } end end # POST /users def create @user = User.new(params[:user]) respond_to do |format| if @user.save format.html { redirect_to(@user, :notice =&gt; 'User was successfully created.') } format.xml { render :xml =&gt; @user, :status =&gt; :created, :location =&gt; @user } else format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @user.errors, :status =&gt; :unprocessable_entity } end end end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload