使用Rails Ajax呈现不同的.js文件

在使用Ajax时,如何呈现不同的.js.erb文件

例如:

<%表单标记用户路径:方法=>:获取:远程=>真do%>

这将通过UserController#show,然后呈现users/show.js.erb。如何让它通过UserController#show,然后呈现users/hello.js.erb

用户\u控制器.rb中:

def show
@user=user.find(参数[:id])
回应待办事项|格式|
format.js{render'hello.js.erb'}
终止
终止

或更短,因为只有一种响应格式:

def show
@user=user.find(参数[:id])
雷德:你好
终止

发表评论