Class: Admin::ApplicationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin/applications_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#require_admin, #set_active_menu

Methods inherited from ApplicationController

#fresh_when, #redirect_back_or_default, #redirect_referrer_or_default, #render_403, #render_404, #render_optional_error_file, #require_user, #set_active_menu, #set_locale, #set_seo_meta, #store_location, #unread_notify_count

Instance Method Details

#createObject


34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/admin/applications_controller.rb', line 34

def create
  @application = Doorkeeper::Application.new(params[:application].permit!)

  respond_to do |format|
    if @application.save
      format.html { redirect_to(admin_applications_path, notice: 'Application 创建成功。') }
      format.json
    else
      format.html { render action: 'new' }
      format.json
    end
  end
end

#destroyObject


62
63
64
65
66
67
68
69
70
# File 'app/controllers/admin/applications_controller.rb', line 62

def destroy
  @application = Doorkeeper::Application.find(params[:id])
  @application.destroy

  respond_to do |format|
    format.html { redirect_to(admin_applications_path, notice: '删除成功。') }
    format.json
  end
end

#editObject


30
31
32
# File 'app/controllers/admin/applications_controller.rb', line 30

def edit
  @application = Doorkeeper::Application.find(params[:id])
end

#indexObject


3
4
5
6
7
8
9
10
# File 'app/controllers/admin/applications_controller.rb', line 3

def index
  @applications = Doorkeeper::Application.order(id: :desc).paginate(page: params[:page], per_page: 20)

  respond_to do |format|
    format.html # index.html.erb
    format.json
  end
end

#newObject


21
22
23
24
25
26
27
28
# File 'app/controllers/admin/applications_controller.rb', line 21

def new
  @application = Doorkeeper::Application.new

  respond_to do |format|
    format.html # new.html.erb
    format.json
  end
end

#showObject


12
13
14
15
16
17
18
19
# File 'app/controllers/admin/applications_controller.rb', line 12

def show
  @application = Doorkeeper::Application.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.json
  end
end

#updateObject


48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/admin/applications_controller.rb', line 48

def update
  @application = Doorkeeper::Application.find(params[:id])

  respond_to do |format|
    if @application.update_attributes(params[:application].permit!)
      format.html { redirect_to(admin_applications_path, notice: 'Application 更新成功。') }
      format.json
    else
      format.html { render action: 'edit' }
      format.json
    end
  end
end