2013-06-07 4 views

ответ

10

Компоненты компоновки activeadmin очень легко настраиваются. Что вам нужно сделать: просто определите модуль, который открывает ActiveAdmin :: View.

вы можете иметь custom_activeadmin_components.rb в инициализаторах или каталоге администратора, где вы определили все свои ресурсы activeadmin. Я предпочитаю поместить его в каталог, в котором находятся ваши ресурсы activeadmin. Затем переопределить любой модуль, который вы хотите:

вот пример:

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

Его расположение относительно не конкретной страницы. Например, вы хотите добавить опцию выбора языка в разделе заголовка, или вы хотите вывести навигаторы вместо типичных navadmin activeadmin. – Muntasim

Смежные вопросы