2013-06-03 30 views

Trả lời

15

Củng cố câu trả lời và bổ sung thêm một chút:

Hầu hết điều này là trên this page on the wiki (hoặc tôi sẽ đưa nó ở đó sớm).

Trong tập tin đó đăng ký mô hình của bạn cho activeadmin (ví dụ như ứng dụng/admin/user.rb), bạn có thể có

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

Theo this post, bạn có thể sử dụng một dòng như sau trong tác động của sự lựa chọn:

@page_title="My Custom Title" 

Ví dụ, để thực hiện điều này trong một hành động tồn tại trước đó như 'mới', bạn sẽ làm điều gì đó như thế này:

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

Sau khi tìm kiếm đã nhận nó,

Bạn có thể thêm: attribute tiêu đề để các khối quản trị hoạt động.

ví dụ

1) Để thiết lập tiêu đề cho trang index,

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

2) Để thiết lập tiêu đề cho trang hiển thị,

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

để biết thêm chi tiết thanh toán: https://github.com/gregbell/active_admin/wiki/Set-page-title – bunty

0

Đơn giản chỉ cần làm

index title: "Me new title" 
Các vấn đề liên quan