views:

60

answers:

1

I get nil from params[:user] in create action of my controller for the first request when I start my mongrel server by using mongrel_rails start. After that for second and third time are ok. In addition, if I start my Mongrel by using script/server, it doesn't have any problems at all. It is different by starting mongrel server between script/server and mongrel_rails start? Have you ever faced this problem?

Here my code in controller:

def create
  @user = User.new(params[:user])

  respond_to do |format|
    if @user.save
      flash[:notice] = 'User was successfully created.'
      format.html { redirect_to(@user) }
      format.xml  { render :xml => @user, :status => :created, :location => @user }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
    end
  end
end

And I use Poster add-on to test and post in xml format.

A: 

First thing you want to check is the new action in your controller. Second is the erb file which has your form. I have a feeling the text field tags are not proper.

I'd recommend inspecting the params object by:

logger.debug params.inspect # Will show up log/development.log
puts params.inspect # Will show up in server console
Swanand
But I don't HTML form to post the data, I use Poster, a firefox addon for testing RESTful webservice, and put the data in message body directly.
Samnang
Oops.. so you don't need to see the html form, but you would still need to inspect the `params` object
Swanand