Class: Admin::ElementsController
- Inherits:
-
AdminController
- Object
- ApplicationController
- AdminController
- Admin::ElementsController
- Defined in:
- app/controllers/admin/elements_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /elements or /elements.json.
-
#destroy ⇒ Object
DELETE /elements/1 or /elements/1.json.
-
#edit ⇒ Object
GET /elements/1/edit.
-
#index ⇒ Object
GET /elements or /elements.json.
-
#new ⇒ Object
GET /elements/new.
-
#show ⇒ Object
GET /elements/1 or /elements/1.json.
- #sort ⇒ Object
-
#update ⇒ Object
PATCH/PUT /elements/1 or /elements/1.json.
Instance Method Details
#create ⇒ Object
POST /elements or /elements.json
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/admin/elements_controller.rb', line 27 def create @element = Element.new(element_params) respond_to do |format| if @element.save format.html { redirect_to admin_element_url(@element), notice: "Element was successfully created." } format.json { render :show, status: :created, location: @element } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @element.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /elements/1 or /elements/1.json
55 56 57 58 59 60 61 62 |
# File 'app/controllers/admin/elements_controller.rb', line 55 def destroy @element.destroy respond_to do |format| format.html { redirect_to admin_elements_url, notice: "Element was successfully destroyed." } format.json { head :no_content } end end |
#edit ⇒ Object
GET /elements/1/edit
23 24 |
# File 'app/controllers/admin/elements_controller.rb', line 23 def edit end |
#index ⇒ Object
GET /elements or /elements.json
9 10 11 |
# File 'app/controllers/admin/elements_controller.rb', line 9 def index @pagy, @elements = pagy(Element.all.order(position: :asc), items: 100) end |
#new ⇒ Object
GET /elements/new
18 19 20 |
# File 'app/controllers/admin/elements_controller.rb', line 18 def new @element = Element.new end |
#show ⇒ Object
GET /elements/1 or /elements/1.json
14 15 |
# File 'app/controllers/admin/elements_controller.rb', line 14 def show end |
#sort ⇒ Object
64 65 66 67 |
# File 'app/controllers/admin/elements_controller.rb', line 64 def sort Element.sort_elements(params[:id_list]) render body: nil end |
#update ⇒ Object
PATCH/PUT /elements/1 or /elements/1.json
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/admin/elements_controller.rb', line 42 def update respond_to do |format| if @element.update(element_params) format.html { redirect_to admin_element_url(@element), notice: "Element was successfully updated." } format.json { render :show, status: :ok, location: @element } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @element.errors, status: :unprocessable_entity } end end end |