Class: Panel::MenusController
- Inherits:
-
BaseController
- Object
- BaseController
- Panel::MenusController
- Defined in:
- app/controllers/wechat/panel/menus_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #edit_parent ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #new_parent ⇒ Object
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/controllers/wechat/panel/menus_controller.rb', line 22 def create @menu = Menu.new() unless @menu.save render :new, locals: { model: @menu }, status: :unprocessable_entity end end |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/wechat/panel/menus_controller.rb', line 30 def edit @parents = Menu.where(type: 'Wechat::ParentMenu', parent_id: nil, appid: @menu.appid) end |
#edit_parent ⇒ Object
34 35 |
# File 'app/controllers/wechat/panel/menus_controller.rb', line 34 def edit_parent end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/wechat/panel/menus_controller.rb', line 6 def index q_params = {} q_params.merge! params.permit(:name) @menus = Menu.includes(:children).where(appid: nil).roots.default_where(q_params).order(parent_id: :desc, position: :asc).page(params[:page]) end |
#new ⇒ Object
13 14 15 16 |
# File 'app/controllers/wechat/panel/menus_controller.rb', line 13 def new @menu = Menu.new(type: 'Wechat::ViewMenu') @parents = Menu.roots.where(appid: nil).where(type: 'Wechat::ParentMenu') end |
#new_parent ⇒ Object
18 19 20 |
# File 'app/controllers/wechat/panel/menus_controller.rb', line 18 def new_parent @menu = Menu.new end |