如何传入object:with field for link_to_remote call

时间:2010-05-27 07:58:40

标签: ruby-on-rails ajax

我有一个对象元素,我想传递给remove_tag_from_cart方法。 这是我的尝试:

-counter.times do |c|
  -elem = @tags[c]
  #{elem.name}#{link_to_remote image_tag('x.png'), :url => {:controller => 'questions', :action => 'remove_tag_from_cart'}, :with => {:tag_to_remove => :elem}}

:with子句无法正常工作。图像甚至没有显示出来。如果我取出:with子句,则链接会正确显示并正确调用方法,但我需要elem对象才能将其从cart中删除。

建议?

1 个答案:

答案 0 :(得分:1)

参考:this

:with:一个JavaScript表达式,指定XMLHttpRequest的参数。任何表达式都应返回有效的URL查询字符串。

示例:

尝试

:with =>"'tag_remove=' + #{elem}"
相关问题