vendredi 23 juin 2017

How do you remove the edit button in an active admin show

I want to remove the edit button on active admin show pages for any record except for those where the month and year equal the current month and year.

I was able to do that in the index with

  if (es.month == Date.today.strftime("%m").to_i) && (es.year == Date.today.strftime("%Y").to_i )
    span link_to 'Edit', "/executive_summaries/#{es.id}/edit"
  end

My executive_summaryies.rb includes

ActiveAdmin.register Executive::Summary do
  menu :parent => 'Reports'

  config.batch_actions = true

 . . .

  action_item :only => :show do
     link_to_function("#{ActiveAdmin::Iconic.icon(:document_stroke)} Print Executive Summary".html_safe, "javascript:print()")

  end

 . . .

 controller do

 . . . 

    def edit
      @run_js_functions = %w(ExecutiveSummaries.init)
    end

    def show
      @run_js_functions = %w(ExecutiveSummaries.accordion)
    end

    . . . 

end

The way the code is currently, the edit button shows in the titlebar (by default I believe) and there is a print button next to it. (From the code in the show above).

How can I just show the edit button for records that are for the current month and year on the show/view page?

Aucun commentaire:

Enregistrer un commentaire