Class: NextSgad::PositionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- NextSgad::PositionsController
- Defined in:
- app/controllers/next_sgad/positions_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /positions.
-
#destroy ⇒ Object
DELETE /positions/1.
-
#edit ⇒ Object
GET /positions/1/edit.
-
#index ⇒ Object
GET /positions.
-
#new ⇒ Object
GET /positions/new.
- #orgchart ⇒ Object
-
#show ⇒ Object
GET /positions/1.
-
#update ⇒ Object
PATCH/PUT /positions/1.
Instance Method Details
#create ⇒ Object
POST /positions
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 26 def create @position = Position.new(position_params) if @position.save redirect_to @position, notice: 'Position was successfully created.' else render :new end end |
#destroy ⇒ Object
DELETE /positions/1
46 47 48 49 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 46 def destroy @position.destroy redirect_to positions_url, notice: 'Position was successfully destroyed.' end |
#edit ⇒ Object
GET /positions/1/edit
22 23 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 22 def edit end |
#index ⇒ Object
GET /positions
8 9 10 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 8 def index @positions = Position.all end |
#new ⇒ Object
GET /positions/new
17 18 19 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 17 def new @position = Position.new end |
#orgchart ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 51 def orgchart @o = (Department.all + Position.all + Employee.all).group_by{|x| [x.class.name, x.id]} @positions = Position.all.group_by{|p| p.position_id} @root = Position.find_by(id: params[:root_id]) || Position.where(position_id: nil).first if @root.present? @return = org_data(@root, @o, @positions) else @return = {} end respond_to do |format| format.html format.json{render json: @return} end end |
#show ⇒ Object
GET /positions/1
13 14 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 13 def show end |
#update ⇒ Object
PATCH/PUT /positions/1
37 38 39 40 41 42 43 |
# File 'app/controllers/next_sgad/positions_controller.rb', line 37 def update if @position.update(position_params) redirect_to @position, notice: 'Position was successfully updated.' else render :edit end end |