0
此代碼是爲ActiveAdmin編寫的,但實際上並不重要。 我如何優化它?謝謝。重構一個選項散列是如何從另一個構建的
module ActiveAdminSimpleMenu
# in options can take:
# menu_priority:integer
# menu_parent:string
# permitted_params:array for some additions to main_fields permitted params
def simple_menu_for(klass, options = {})
ActiveAdmin.register klass do
menu_options = {}
menu_options[:priority] = options[:menu_priority] if options[:menu_priority]
menu_options[:parent] = options[:menu_parent] if options[:menu_parent]
menu menu_options unless menu_options.empty?
permit_params(*(klass.main_fields + (options[:permitted_params] ? options[:permitted_params] : [])))
...
謝謝,男人! –