当我点击“创建”时,如何防止“Simple_form_for”重定向或刷新?

时间:2017-12-17 19:41:24

标签: ruby-on-rails simple-form

我的问题是每当我打字创建一个新对象时,表单会自行刷新并且无法将其保存到数据库

String lastSentence=somethingalreadydoneabove;
    String upperCase=lastSentence.toUpperCase();

  # POST /customers
  # POST /customers.json
  def create
    respond_to do |format|
      @refund = Refund.all.map{ |c| [c.status, c.id]}
      @customer = current_user.customers.build(customer_params)
      @customer.refund_id = params[:refund_id]

      if @customer.save
        format.html { redirect_to @customer, notice: "You have successfully added a refund for #{@customer.last_name}." }
        format.json { render :show, status: :created, location: @customer }
  else
    format.html { render :new }
    format.json { render json: @customer.errors, status: :unprocessable_entity }
  end
end

##

0 个答案:

没有答案