diff --git a/app/controllers/guidances_controller.rb b/app/controllers/guidances_controller.rb index 31036f4..eeed41b 100644 --- a/app/controllers/guidances_controller.rb +++ b/app/controllers/guidances_controller.rb @@ -11,19 +11,23 @@ end def admin_new - @guidance = Guidance.new - authorize @guidance - @themes = Theme.all.order('title') - @guidance_groups = GuidanceGroup.where(org_id: current_user.org_id).order('name ASC') + guidance = Guidance.new + authorize guidance + themes = Theme.all.order('title') + guidance_groups = GuidanceGroup.where(org_id: current_user.org_id).order('name ASC') + render(:new_edit, locals: { guidance: guidance, themes: themes, + guidance_groups: guidance_groups, options: { url: admin_create_guidance_path, method: :post }}) end ## # GET /guidances/1/edit def admin_edit - @guidance = Guidance.eager_load(:themes, :guidance_group).find(params[:id]) - authorize @guidance - @themes = Theme.all.order('title') - @guidance_groups = GuidanceGroup.where(org_id: current_user.org_id).order('name ASC') + guidance = Guidance.eager_load(:themes, :guidance_group).find(params[:id]) + authorize guidance + themes = Theme.all.order('title') + guidance_groups = GuidanceGroup.where(org_id: current_user.org_id).order('name ASC') + render(:new_edit, locals: { guidance: guidance, themes: themes, + guidance_groups: guidance_groups, options: { url: admin_update_guidance_path(guidance), method: :put }}) end ## diff --git a/app/views/guidances/new_edit.html.erb b/app/views/guidances/new_edit.html.erb new file mode 100644 index 0000000..79a995c --- /dev/null +++ b/app/views/guidances/new_edit.html.erb @@ -0,0 +1,32 @@ +<%# locals: { guidance, themes, guidance_groups, options } %> +