3lviend
3lviend

Reputation: 353

how to rename button new in index active admin rails

how to rename button new text in index active admin rails? example, i have button with value "New Book", how to change the text in button to "New Book Adventure"

i have code like this :

action_item :only => :index do
    config.clear_action_items!
    link_to "New Book Adventure" , "/admin/books/new" 
  end

but i get duplicate button in index page active admin?

Upvotes: 13

Views: 3994

Answers (2)

ronnyworm
ronnyworm

Reputation: 51

The config.clear_action_items! has a lot of side effects, therefore I'd recommend checking this instead: https://activeadmin.info/2-resource-customization.html -> Renaming Action Items

Here is a summary: Change the config/locales/[en].yml:

en:
  active_admin:
    resources:
      book: # Registered resource
        new_model: 'New Book Adventure' # new action item
        edit_model: 'Change Book Adventure' # edit action item
        delete_model: 'Delete Book Adventure' # delete action item

Upvotes: 0

rorofromfrance
rorofromfrance

Reputation: 1904

You just need to get the config.clear_action_items! line out of your action_item block

Just like this:

config.clear_action_items!

action_item only: :index do
  link_to 'New Book Adventure', '/admin/books/new'
end

Upvotes: 21

Related Questions