Class: EditRequestsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #require_admin_user

Instance Method Details

#editObject

GET /edit_requests/1/edit



8
9
10
11
12
13
# File 'app/controllers/edit_requests_controller.rb', line 8

def edit
  unless current_user.superuser || current_user.sysadmin || current_user.trainer
    flash[:notice] = I18n.t(:no_modify_submitted)
    redirect_to request_path(@request_model)
  end
end

#updateObject

PATCH/PUT /edit_requests/1 or /edit_requests/1.json



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/edit_requests_controller.rb', line 16

def update
  if current_user.superuser || current_user.sysadmin || current_user.trainer
    respond_to do |format|
      if @request_model.update(request_params) && @request_model.valid_to_submit?
        format.html { redirect_to request_url(@request_model), notice: I18n.t(:successful_update) }
        format.json { render :show, status: :ok, location: @request_model }
      else
        format.html { render :edit, status: :unprocessable_entity }
        format.json { render json: @request_model.errors, status: :unprocessable_entity }
      end
    end
  else
    flash[:notice] = I18n.t(:no_modify_submitted)
    redirect_to request_path(@request_model)
  end
end