From 3bf16e0419955fe809be582c413e3a8ba97e9955 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Wed, 5 Feb 2020 15:09:24 +0800 Subject: [PATCH] add :edit action --- .../admin/activities_controller.rb | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/activities_controller.rb b/app/controllers/admin/activities_controller.rb index def7116..2e85ac1 100644 --- a/app/controllers/admin/activities_controller.rb +++ b/app/controllers/admin/activities_controller.rb @@ -2,9 +2,8 @@ class Admin::ActivitiesController < OrbitMemberController layout "member_plugin" #include Admin::PersonalActivitiesHelper - #before_action :set_writing_conference, only: [:show, :edit , :update, :destroy] + before_action :set_activity, only: [:edit] #before_action :set_plugin - #before_action :get_settings,:only => [:new, :edit, :setting] #before_action :need_access_right #before_action :allow_admin_only, :only => [:index, :setting] @@ -16,4 +15,21 @@ class Admin::ActivitiesController < OrbitMemberController format.xml { render :xml => @activities } end end + + def edit + end + + private + + def set_activity + path = request.path.split('/') + if path.last.include? '-' + uid = path[-1].split("-").last + uid = uid.split("?").first + else + uid = path[-2].split("-").last + uid = uid.split("?").first + end + @activity = Activity.find_by(:uid => uid) rescue Activity.find(params[:id]) + end end