如何使用json / ajax方法添加删除和编辑按钮列?
<%= link_to image_tag('icons/edit.png'), editcontent_path(page), :title => "edit" %>
<%= link_to image_tag('icons/delete.png'), page, method: :delete, data: { confirm: 'Are you sure?' }, :title => "delete" %>
我想输入datatables / page_datatables.rb
class PagesDatatable
delegate :params, :truncate, :html_safe, :link_to, to: :@view
.....
def data
pages.map do |page|
[
page.name
page.permalink,
truncate(page.content, :length => 160).html_safe
##### I want to input here ####
]
end
end
......
......
end
请帮助..
答案 0 :(得分:1)
这对我有用,
class PagesDatatable
delegate :params, :truncate, :html_safe, :link_to, :edit_page_path, :page, to: :@view
.....
.....
def data
pages.map do |page|
[
page.name,
page.permalink,
truncate(page.content, :length => 160).html_safe,
link_to("edit", edit_page_path(page)),
link_to("delete", page, method: :delete, data: { confirm: 'Are you sure?' })
]
end
end
end
答案 1 :(得分:0)
需要查看您的路线。但是,您可以通过以下示例获得灯光:
<%= link_to image_tag('icons/edit.png'), [:edit, page], :title => "edit" %>
<%= link_to image_tag('icons/delete.png'), page, :method => :delete, :confirm => 'Are you sure?', :title => "delete" %>