Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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 RubyonRails通过重定向发送值_Ruby On Rails_Ruby_Ruby On Rails 3_Redirect - Fatal编程技术网

Ruby on rails RubyonRails通过重定向发送值

Ruby on rails RubyonRails通过重定向发送值,ruby-on-rails,ruby,ruby-on-rails-3,redirect,Ruby On Rails,Ruby,Ruby On Rails 3,Redirect,这里(@empreset.ad=@id)的逻辑也可以是format.html{redirect_to:action=>:index,:id=>@id} 也可以。但是错误发生了。。 在控制器索引中,我必须发送id值。因为@empreset.ad对所有数据具有相同的值。我需要发送一个@empreset.ad value。但既然@empreset.ad在数组中,这怎么可能呢。如何仅选取@empreset.ad的一个值并发送 重定向:id=>@empreset.ad?@empreset是一个数组,对吗?

这里(@empreset.ad=@id)的逻辑也可以是format.html{redirect_to:action=>:index,:id=>@id} 也可以。但是错误发生了。。 在控制器索引中,我必须发送id值。因为@empreset.ad对所有数据具有相同的值。我需要发送一个@empreset.ad value。但既然@empreset.ad在数组中,这怎么可能呢。如何仅选取@empreset.ad的一个值并发送


重定向:id=>@empreset.ad?

@empreset是一个数组,对吗? 要发送此数组的一个值,请使用@empreset.first.ad
这将获得数组第一个元素的属性ad。

再写一行。empreset=@empreset.first

然后


format.html{redirect_to:action=>:index,:id=>empreset.ad}

然后在上面的行中使用一个变量并传递给id。
    @id =params[:ad]
   @empreasset = params[:check_box_id]
    case params[:commit]
    when 'delete'
      @empreasset.each do |empreasset|
        @em = Empreasset.find(empreasset)
        @em.destroy
  end
  @size=@empreasset.size
  @message = "#{@size} Employee asset(s) deleted sucessfully"
  respond_to do |format|

      format.html {redirect_to :action => :index, :id => @empreasset.ad}
      format.json {head :no_content}

end