为什么我的日期字段在会话中不起作用?

时间:2012-08-07 16:35:44

标签: ruby ruby-on-rails-3.1

当我在我的控制器中执行此操作时:

def new
    @army = Army.new(strength: session[:last_army_strength], 
                     type_id: session[:last_type]),
                     date: session[:last_date])
end

def create
    @army = current_user.armies.new(params[:army])
    session[:last_army_strength] = params[:army][:strength]
    session[:last_type] = params[:army][:type_id]
    session[:last_date] = params[:army][:date]
    respond_to do |format|
      if @army.save
        format.html { redirect_to new_army_path, :notice => "New army added" }
      else
        format.html { render :new }
      end
    end
  end
end

type_idstrength字段已保存,但我的date字段会自行重置。这是为什么?

0 个答案:

没有答案