Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何在rails应用程序中发送xml请求_Ruby On Rails_Xml - Fatal编程技术网

Ruby on rails 如何在rails应用程序中发送xml请求

Ruby on rails 如何在rails应用程序中发送xml请求,ruby-on-rails,xml,Ruby On Rails,Xml,我的应用程序中有这个按钮 <%= button_to t('.add_html'), :class => "line-item", :product => product.id %> 我的控制器创建操作 def创建 @购物车=当前购物车 product=product.findparams[:product\u id] @行\u item=@cart.add\u productproduct.id respond_to do |format| if

我的应用程序中有这个按钮

 <%= button_to t('.add_html'), :class => "line-item", :product => product.id %>
我的控制器创建操作 def创建 @购物车=当前购物车 product=product.findparams[:product\u id] @行\u item=@cart.add\u productproduct.id

    respond_to do |format|
      if @line_item.save
        format.html { redirect_to(store_url) }
        format.js { @current_item = @line_item }
        format.xml  { render :xml => @line_item,
                             :status => :created, :location => @line_item }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @line_item.errors,
                             :status => :unprocessable_entity }
      end
    end
  end
我该怎么做?

试试这个:

<%= button_to t('.add_html'), action: :create, format: :xml, :class => "line-item" %>

@user1478137,两者都应该起作用。我之所以编辑,是因为我不想根据您的控制器生成我暗示的路径。
<%= button_to t('.add_html'), action: :create, format: :xml, :class => "line-item" %>