Class: Share::MenusController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/wechat/share/menus_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



29
30
31
32
33
34
35
# File 'app/controllers/wechat/share/menus_controller.rb', line 29

def create
  @menu = @app.menus.new(menu_params)

  unless @menu.save
    render :new, locals: { model: @menu }, status: :unprocessable_entity
  end
end

#destroyObject



60
61
62
# File 'app/controllers/wechat/share/menus_controller.rb', line 60

def destroy
  @menu.destroy
end

#editObject



45
46
47
# File 'app/controllers/wechat/share/menus_controller.rb', line 45

def edit
  @parents = Menu.where(type: 'Wechat::ParentMenu', parent_id: nil, appid: @menu.appid)
end

#edit_parentObject



49
50
# File 'app/controllers/wechat/share/menus_controller.rb', line 49

def edit_parent
end

#indexObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/wechat/share/menus_controller.rb', line 8

def index
  q_params = {}
  q_params.merge! params.permit(:name)

  @default_menus = Menu.roots.where(appid: nil).where(q_params).order(parent_id: :desc, position: :asc)
  @menus = @app.menus.roots.where(q_params).order(parent_id: :desc, position: :asc)

  @scene_menu_ids = @scene.scene_menus.pluck(:menu_id)
end

#newObject



18
19
20
21
22
23
# File 'app/controllers/wechat/share/menus_controller.rb', line 18

def new
  @menu = @app.menus.build(type: 'Wechat::ViewMenu')
  @menu.scene_menus.build

  @parents = Menu.where(type: 'Wechat::ParentMenu', parent_id: nil, appid: params[:appid])
end

#new_parentObject



25
26
27
# File 'app/controllers/wechat/share/menus_controller.rb', line 25

def new_parent
  @menu = Menu.new(appid: params[:appid])
end

#showObject



42
43
# File 'app/controllers/wechat/share/menus_controller.rb', line 42

def show
end

#syncObject



37
38
39
40
# File 'app/controllers/wechat/share/menus_controller.rb', line 37

def sync
  r = @app.sync_menu
  render 'sync', locals: { notice: r.to_s }
end

#updateObject



52
53
54
55
56
57
58
# File 'app/controllers/wechat/share/menus_controller.rb', line 52

def update
  @menu.assign_attributes(menu_params)

  unless @menu.save
    render :edit, locals: { model: @menu }, status: :unprocessable_entity
  end
end