我有一个link_to方法似乎被解释为JS, 而我希望它是JSON。
此,
<%= link_to("Destroy", tour_event_path(tour, result), :id => 'delete_event', :remote => true, :method => :delete, :html => {:'data-type' => 'json'} )%>
结果
Processing by EventsController#destroy as JS
我想要的是
Processing by EventsController#destroy as JSON
我在另一个SO答案中添加了, :html => {:'data-type' => 'json'}
,但没有运气。
我在轨道上4.有什么想法吗?
答案 0 :(得分:2)
<%= link_to("Destroy",tour_event_path(tour, result,:format => :json ), id: 'delete_event',remote: true,method: :delete )
%>
答案 1 :(得分:1)
写下您的link_to
,如下所示:
<%=
link_to(
"Destroy",
tour_event_path(tour, result),
id: 'delete_event',
remote: true,
method: :delete,
data: { type: 'json' }
)
%>