|
|
@ -27,8 +27,9 @@ class SchemesController < ApplicationController |
|
|
|
def create |
|
|
|
def create |
|
|
|
@scheme = Scheme.new(scheme_params) |
|
|
|
@scheme = Scheme.new(scheme_params) |
|
|
|
if @scheme.save |
|
|
|
if @scheme.save |
|
|
|
render "schemes/primary_client_group" |
|
|
|
redirect_to scheme_primary_client_group_path(@scheme) |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
debugger |
|
|
|
@scheme.errors.add(:owning_organisation_id, message: @scheme.errors[:organisation]) |
|
|
|
@scheme.errors.add(:owning_organisation_id, message: @scheme.errors[:organisation]) |
|
|
|
@scheme.errors.delete(:owning_organisation) |
|
|
|
@scheme.errors.delete(:owning_organisation) |
|
|
|
render :new, status: :unprocessable_entity |
|
|
|
render :new, status: :unprocessable_entity |
|
|
@ -51,7 +52,7 @@ class SchemesController < ApplicationController |
|
|
|
redirect_to next_page_path params[:scheme][:page] |
|
|
|
redirect_to next_page_path params[:scheme][:page] |
|
|
|
end |
|
|
|
end |
|
|
|
else |
|
|
|
else |
|
|
|
render request.current_url, status: :unprocessable_entity |
|
|
|
render current_template(request.referer), status: :unprocessable_entity |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -89,6 +90,13 @@ private |
|
|
|
page == "confirm-secondary" && @scheme.has_other_client_group == "Yes" |
|
|
|
page == "confirm-secondary" && @scheme.has_other_client_group == "Yes" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def current_template(page) |
|
|
|
|
|
|
|
case |
|
|
|
|
|
|
|
when page.include?("primary") |
|
|
|
|
|
|
|
"schemes/primary_client_group" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def next_page_path(page) |
|
|
|
def next_page_path(page) |
|
|
|
case page |
|
|
|
case page |
|
|
|
when "primary-client-group" |
|
|
|
when "primary-client-group" |
|
|
|