Class: Dashboard::NavigationsController
- Inherits:
-
BaseController
- Object
- BaseController
- Dashboard::NavigationsController
- Defined in:
- app/controllers/blacksand/dashboard/navigations_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /navigations POST /navigations.json.
-
#destroy ⇒ Object
DELETE /navigations/1 DELETE /navigations/1.json.
-
#edit ⇒ Object
GET /navigations/1/edit.
-
#index ⇒ Object
GET /navigations GET /navigations.json.
-
#new ⇒ Object
GET /navigations/new.
- #reorder ⇒ Object
-
#show ⇒ Object
GET /navigations/1 GET /navigations/1.json.
-
#update ⇒ Object
PATCH/PUT /navigations/1 PATCH/PUT /navigations/1.json.
Instance Method Details
#create ⇒ Object
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() respond_to do |format| if @navigation.save format.html { redirect_to , 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 |
#destroy ⇒ Object
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 , notice: 'Navigation was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /navigations/1/edit
34 35 |
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 34 def edit end |
#index ⇒ Object
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 |
#new ⇒ Object
GET /navigations/new
29 30 31 |
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 29 def new @navigation = Navigation.new end |
#reorder ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 11 def reorder = params[: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 |
#show ⇒ Object
GET /navigations/1 GET /navigations/1.json
25 26 |
# File 'app/controllers/blacksand/dashboard/navigations_controller.rb', line 25 def show end |
#update ⇒ Object
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() format.html { redirect_to , 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 |