portagenetwork / roadmap

Developed by the the Alliance in collaboration with University of Alberta, DMP Assistant a data management planning tool, forking the DMP Roadmap codebase
MIT License
6 stars 1 forks source link

500 Error When Switching Language on Some URL Paths #708

Open aaronskiba opened 3 months ago

aaronskiba commented 3 months ago

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0) 4.0.2+portage-4.0.2

Expected behaviour:

Actual behaviour:

Diagnosis

app/controllers/session_locales_controller.rb

class SessionLocalesController < ApplicationController
  def update
    session[:locale] = params[:locale] if available_locales.include?(params[:locale].intern)
    redirect_back(fallback_location: root_path)
  end

e.g. app/controllers/super_admin/api_clients_controller.rb

    # PATCH/PUT /api_clients/:id
    # rubocop:disable Metrics/AbcSize
    def update
      ...
      ...
      ...
      render :edit
    end

    # GET /api_clients/1/edit
    def edit
      @api_client = ApiClient.find(params[:id])
      authorize(@api_client)
    end

After performing the update action, the edit view is rendered. However, the URL path remains at /api_clients/:id. But there is no controller action corresponding to GET /api_clients/:id. Thus, a 500 error is triggered when trying to change languages via the language dropdown (screenshot below):

Screenshot from 2024-03-28 14-43-55

aaronskiba commented 3 months ago

Here is a list of controller actions that call render as well as their corresponding paths (when provided in the codebase). These are "non-GET actions" whose paths do not have a corresponding GET method. As a result, when using the language selector on these paths, a 500 error should be triggered.


# app/controllers/contributors_controller.rb

# DELETE /plans/:plan_id/contributors/:id
  def destroy
    render :edit
  end

# PUT /plans/:plan_id/contributors/:id
  def update
    render :edit
  end

# app/controllers/guidance_groups_controller.rb

# POST /org/admin/guidancegroup/:id/admin_create
  def admin_create
    render :admin_edit
    render :admin_new
  end

# PUT /org/admin/guidancegroup/:id/admin_update
  def admin_update
    render :admin_edit
  end

# app/controllers/guidances_controller.rb

# POST /org/admin/guidance/:id/admin_create
  def admin_create
    render :new_edit
  end

# PUT /org/admin/guidance/:id/admin_update
  def admin_update
    render :new_edit
  end

# app/controllers/org_admin/departments_controller.rb

# POST /departments
# POST /departments.json
def create
  render :new
end

# PUT /departments/1
def update
  render :edit
end

# app/controllers/org_admin/users_controller.rb

def update
  render :edit
end

# PATCH/PUT /notifications/1
# PATCH/PUT /notifications/1.json
def update
  render :edit
end

# DELETE /notifications/1
# DELETE /notifications/1.json
def destroy
  render :edit
end

# app/controllers/super_admin/themes_controller.rb

def update
  render :edit
end

def destroy
  render :edit
end

# app/controllers/super_admin/users_controller.rb

# PUT /super_admin/users/:id
def update
  render :edit
end

# PUT /super_admin/users/:id/merge
def merge
  render :edit
end

# PUT /super_admin/users/:id/archive
def archive
  render :edit
end