如何使URL助手以给定的请求/响应格式创建URL?
例如,在我的测试中,我有以下内容:
get(activity_url(activity))
这将为我返回
@response
对象上的HTML。我希望具有以下相同的行为:get({controller: 'activities', action: 'show', id: activity.id, format: 'js'})
但没有所有这些措辞。可能吗?
最佳答案
您应该能够执行以下操作:
some_resource_path(format: :json)
要么
some_resource_url(format: :xml)
关于ruby-on-rails - Rails-如何向网址帮助器添加格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16701212/