Class: Dashboard::NavigationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/blacksand/dashboard/navigations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /navigations POST /navigations.json



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 39

def create
  @navigation = Navigation.new(navigation_params)

  respond_to do |format|
    if @navigation.save
      format.html { redirect_to navigations_url, notice: 'Navigation was successfully created.' }
      format.json { render :show, status: :created, location: [:dashboard, @navigation] }
    else
      format.html { render :new }
      format.json { render json: @navigation.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /navigations/1 DELETE /navigations/1.json



69
70
71
72
73
74
75
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 69

def destroy
  @navigation.destroy
  respond_to do |format|
    format.html { redirect_to navigations_url, notice: 'Navigation was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /navigations/1/edit



34
35
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 34

def edit
end

#indexObject

GET /navigations GET /navigations.json



7
8
9
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 7

def index
  @navigations = Navigation.order(:position)
end

#newObject

GET /navigations/new



29
30
31
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 29

def new
  @navigation = Navigation.new
end

#reorderObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 11

def reorder
  navigations = params[:navigations]
  navigations.each_with_index do |id, index|
    Navigation.update(id, {position: index})
  end

  respond_to do |format|
    format.json { render json: {success: true} }
    format.js { flash.now.notice = '保存成功' }
  end
end

#showObject

GET /navigations/1 GET /navigations/1.json



25
26
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 25

def show
end

#updateObject

PATCH/PUT /navigations/1 PATCH/PUT /navigations/1.json



55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 55

def update
  respond_to do |format|
    if @navigation.update(navigation_params)
      format.html { redirect_to navigations_url, notice: 'Navigation was successfully updated.' }
      format.json { render :show, status: :ok, location: @navigation }
    else
      format.html { render :edit }
      format.json { render json: @navigation.errors, status: :unprocessable_entity }
    end
  end
end