简体   繁体   中英

Can't get value params[:user] first request using mongrel_rails start?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM