2013-06-07 2 views

답변

10

activeadmin 레이아웃 구성 요소는 매우 쉽게 사용자 정의 할 수 있습니다. 필요한 작업 : ActiveAdmin :: View를 여는 모듈을 정의하면됩니다.

activeadmin 리소스를 모두 정의한 초기화 프로그램 또는 admin 디렉토리에 custom_activeadmin_components.rb를 가질 수 있습니다. activeadmin 리소스가있는 디렉토리에 두는 편을 선호합니다. 그런 다음 당신이 원하는 모든 모듈 오버라이드 (override) :

module ActiveAdmin 
    module Views 
    class Header < Component 
     def build(namespace, menu) 
     super(:id => "header") 

     @namespace = namespace 
     @menu = menu 
     @utility_menu = @namespace.fetch_menu(:utility_navigation) 

     build_site_title 
     build_global_navigation 
     build_utility_navigation 
     #you can add any other component here in header section 
     end 

     def build_site_title 
     render "admin/parts/logo" 
     end 

     def build_global_navigation 
     render "admin/parts/main_nav" 
     end 

     def build_utility_navigation 
     render 'admin/parts/language_options' 
     insert_tag view_factory.global_navigation, @utility_menu, :id => "utility_nav", :class => 'header-item tabs' 
     render 'admin/parts/branch_in_header' 
     end 
    end 

    module Pages 
     class Base 
     def build_page_content 
      build_flash_messages 

      div :id => :wizard_progress_bar do 
      render 'admin/parts/wizard_progress_bar' 
      end 

      div :id => "active_admin_content", :class => (skip_sidebar? ? "without_sidebar" : "with_sidebar") do 
      build_main_content_wrapper 
      build_sidebar unless skip_sidebar? 
      end 
     end 
     end 
    end 
    end 
end 
+0

리소스 폴더에 넣어하는 작업하지 않습니다. : –

+0

다른 리소스는 같은 디렉토리에 있습니까? – Muntasim

+0

은 매력처럼 작동합니다. – Rubyrider

0

당신은 관리자/your_model.rb 파일에 활성화 된 관리자 페이지를 사용자 정의 할 수 있습니다 : 여기

은 샘플입니다.

활성 관리자 용 샘플 코드는 다음과 같습니다.

ActiveAdmin.register User do 

    menu :label => "Our User", :priority => 3 #rename menu & set priority# 
    #for index page# 
    index :title => 'Our User' do #set page title# 
    # index :download_links => false do 
     selectable_column 
     column :title 
     column :category do |e| #want to change name of category 
     e.categoryone 
     end 
     column :address 
     default_actions#this will add default action i.e. show|edit|delete# 
    end 
    #end index# 

    #for controller# 
    controller do 
    actions :all, :except => [:edit, :new] # you can decide which all methods to be shown in show page. 
    end 
    #end controller# 

    #show start page# 
    show do |user| 
    h3 "User Details" 
    attributes_table do 
     row :title 
     row :description  
     row :address, :label=>"User Address" #overide address label 
     row :country 
     row :approval 
    end 

    h3 "Activity Photoes" 
    attributes_table do 
     user.uploads.each do |img| #call associated model. Here i want to display uploaded image of upload.rb file 
     row(" ") do 
      link_to image_tag(img.to_jq_upload['small_url']), admin_upload_path(img)#here i have added upload module to admin thats y i can directly give path to the upload record of admin module# 
     end 
     end 
    end 
    active_admin_comments # to show comment block of active admin 
    end 
    #show end# 

    #filer(search) start righthand side panel# 
    filter :title 
    filter :category 
    filter :address 
    #end filter# 

    #for menu on show page# 
    action_item only:[:show] do # this add "Approve User" button on the right hand side of show menu only as we have specified only show method 
    if User.find(params[:id]).approval == true 
     link_to "Approve User", approv_user_path(:id => params[:id])#call custom method of normal rails controller# 
    end 
    end 
    #end menu# 

    #start add side bar on page# 
    sidebar "Project Details" do 
    ul do 
     li link_to("Profile", new_project_path) 
    end 
    end 
    #end side bar# 

+4

레이아웃과 관련된 특정 페이지가 아닙니다. 예를 들어 헤더 섹션에 언어 선택 옵션을 추가하거나 일반적인 activeadmin nav 대신 nav를 드롭 다운하려는 경우가 있습니다. – Muntasim

관련 문제