Rails:如何在控制器中呈现其他动作,在js中不在html中?(Rails : how to render an other action in the controller, in js not in html?)
我的控制器中有两个动作:
def find @item = Item.find(params[:id]) render 'result', :id => @item.id end def result @item = Item.find(params[:id]) respond_to do |format| format.js end end问题在于我首先调用find动作,然后调用result动作但是采用html格式。 所以'format.js`永远不会被触发。
如何在find操作结束时以js格式呈现result操作?
非常感谢 !
I have two actions in my controller :
def find @item = Item.find(params[:id]) render 'result', :id => @item.id end def result @item = Item.find(params[:id]) respond_to do |format| format.js end endThe issue in that I call first the find action, then it calls the result action but in the html format. So the 'format.js` is never triggered.
How can render, at the end of the find action, the result action in the js format ?
Thanks a lot !
最满意答案
在你的find方法中尝试这个。
render 'result', :id => @item.id, :format => :jsTry this in your find method.
render 'result', :id => @item.id, :format => :js更多推荐
发布评论