Class: Panel::AppsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/wechat/panel/apps_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/wechat/panel/apps_controller.rb', line 16

def create
  @app = App.find_or_initialize_by(appid: app_params[:appid])
  if @app.organ
    @app.errors.add :base, '该账号已在其他组织添加,请联系客服'
  end
  @app.assign_attributes app_params

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

#indexObject



5
6
7
8
9
10
# File 'app/controllers/wechat/panel/apps_controller.rb', line 5

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

  @apps = App.default_where(q_params).order(id: :asc).page(params[:page])
end

#newObject



12
13
14
# File 'app/controllers/wechat/panel/apps_controller.rb', line 12

def new
  @app = App.new
end