I'm using ASIFormDataRequest to send multipart POST data to a server rails.
The code snippet where I set the value with a text field and than send POST is below:
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];
In my rails log console I don't have any error and the post started correctly.
The problem is in the INSERT where the value of "name" is NULL:
Started POST "/users"
Parameters: {"name"=>"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')
Has anyone had this problem before?
This is the server side code
class UsersController < ApplicationController
# GET /users/new
def new
@user = User.new
respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @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 => 'User was successfully created.') }
    format.xml  { render :xml => @user, :status => :created, :location => @user }
  else
    format.html { render :action => "new" }
    f开发者_运维技巧ormat.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
  end
end
end
end
My ruby isn't strong so don't shoot me if this is wrong. But shouldn't the line:
 @user = User.new(params[:user])
be
 @user = User.new(params[:name])
?
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论