7

Activeadmin レイアウトは単なるファイルではなく、コンポーネントのコレクションです。

ロゴ、ナビゲーションなどのコンポーネントの一部をactiveadminでオーバーライドするにはどうすればよいですか。

4

2 に答える 2

0

admin/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#

終わり

于 2013-06-07T12:52:56.077 に答える