2013-06-03 13 views

risposta

15

Consolidare le risposte e l'aggiunta di un po ':

La maggior parte di questo è su this page on the wiki (o lo metto lì presto).

All'interno del file che registra il tuo modello per activeadmin (ad esempio app/admin/user.rb), si può avere

ActiveAdmin.register User do 
    # a simple string 
    index :title => "Here's a list of users" do 
    ... 
    end 

    # using a method called on the instance of the model 
    show :title => :name do 
    ... 
    end 

    # more flexibly using information from the model instance 
    show :title => proc {|user| "Details for "+user.name } do 
    ... 
    end 

    # for new, edit, and delete you have to do it differently 
    controller do 
    def edit 
     # use resource.some_method to access information about what you're editing 
     @page_title = "Hey, edit this user called "+resource.name 
    end 
    end 
end 
1

Come da this post, è possibile utilizzare una linea come la seguente nell'azione di scelta:

@page_title="My Custom Title" 

Ad esempio, per attuare questo in un'azione pre-esistenti come 'nuovo', si dovrebbe fare qualcosa in questo modo:

controller do 
    def new do 
    @page_title="My Custom Title" 
    new! do |format| 
     format.html{render "my_new"} 
    end 
    end 
end 
9

dopo la ricerca ha ottenuto,

è possibile aggiungere: title per blocchi di amministrazione attiva.

esempio

1) Per impostare titolo per la pagina di indice,

index :title => 'Your_page_name' do 
.... 
end 

2) Per impostare il titolo per l'esposizione pagina

show :title => 'Your_page_name' do 
.... 
end 
+1

Per ulteriori dettagli checkout: https://github.com/gregbell/active_admin/wiki/Set-page-title – bunty

0

semplicemente

index title: "Me new title" 
Problemi correlati