0

状态资源(由“rails g scaffold Status”生成)

resources :statuses

链接销毁对象

 <%= link_to "delete", status, :confirm => "are you sure?", :method => :delete%>

布局.html.erb

<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>

应用程序.js

//= require jquery
//= require jquery_ujs

导轨 4.0.0

当我点击它时,它会将我重定向到 Rails 的脚手架页面(状态列表)。我如何将用户重定向到主页,或者更好,在以前的页面上

4

1 回答 1

1

statuses_controller.rb你应该destroy采取行动

  def destroy
    @status = Status.find(params[:id]) # or find(params[:status_id]) depends on how route is built
    @status.destroy

    respond_to do |format|
      format.html { redirect_to statuses_url }
      format.json { head :no_content }
    end
  end

更改它将使您从请求开始的位置或redirect_to statuses_url主页返回。redirect_to :backredirect_to root_url

于 2013-07-01T22:17:42.673 回答