1

How can I add delete and edit button column using the json/ajax approach?

<%= 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"  %> 

i want to input on 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

please help ..

2 Answers 2

1

it's work for me,

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
Sign up to request clarification or add additional context in comments.

Comments

0

Need to see your routes. However, you may get lights from the following example:

<%= 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"  %> 

1 Comment

how do I properly link to an edit path end delete in PagesDatatable? It gives me a no method error if I do link_to("edit", edit_page_path(page))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.