当重定向Rails没有在浏览器

时间:2015-07-14 15:59:40

标签: ruby-on-rails ruby-on-rails-4

当我尝试使用此方法时

  def create
    @ticket = current_user.creator.build(ticket_params)
    if @ticket.save!
      flash[:success] = "Thanks! I'll be in touch soon!"
      redirect_to @ticket
    else
      render :root
    end
  end

它在数据库中保存了完美的票证记录。并返回' show'页面的HTML作为回复,但在浏览器中仍然在同一页

此方法创建的响应和两个请求是:

enter image description here

我的表格:

= simple_form_for(@ticket, html: { class: 'form-horizontal', multipart: true  }, remote: true) do |f|

#.....

  = f.submit 'Criar Ticket', class: 'btn btn-primary'

1 个答案:

答案 0 :(得分:1)

您在表单中将remote设置为true,因此发出了javascript请求。但是,您的控制器通过重定向响应,就好像它是一个html请求。为什么要将远程设置为true?如果没有充分的理由,只需删除remote: true即可。

相关问题