From 8f464a960dbf5f8508800cbf0d4ef87475e9e88a Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 2 Oct 2014 19:50:56 +0800 Subject: [PATCH] fix for conference without name --- .../admin/writing_conferences_controller.rb | 18 ++++++++++++++---- .../_writing_conference.html.erb | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/writing_conferences_controller.rb b/app/controllers/admin/writing_conferences_controller.rb index 2ee51f0..82aa57e 100644 --- a/app/controllers/admin/writing_conferences_controller.rb +++ b/app/controllers/admin/writing_conferences_controller.rb @@ -1,6 +1,7 @@ class Admin::WritingConferencesController < OrbitMemberController layout "member_plugin" + before_action :set_writing_conference, only: [:show, :edit , :update, :destroy] before_action :set_plugin before_action :get_settings,:only => [:new, :edit, :setting] @@ -24,20 +25,17 @@ class Admin::WritingConferencesController < OrbitMemberController end def edit - @writing_conference = WritingConference.find(params[:id]) @member = @writing_conference.member_profile end def update - @member = MemberProfile.find(conference_params['member_profile_id']) rescue nil - @writing_conference = WritingConference.find(params[:id]) + @member = @writing_conference.member_profile @writing_conference.update_attributes(conference_params) @writing_conference.save redirect_to params['referer_url'] end def destroy - @writing_conference = WritingConference.find(params[:id]) @writing_conference.destroy end @@ -84,6 +82,18 @@ class Admin::WritingConferencesController < OrbitMemberController private + def set_writing_conference + 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 + @writing_conference = WritingConference.find_by(:uid => uid) rescue WritingConference.find(params[:id]) + end + def conference_params params.require(:writing_conference).permit! rescue nil end diff --git a/app/views/admin/writing_conferences/_writing_conference.html.erb b/app/views/admin/writing_conferences/_writing_conference.html.erb index dc0ec21..ff1f873 100644 --- a/app/views/admin/writing_conferences/_writing_conference.html.erb +++ b/app/views/admin/writing_conferences/_writing_conference.html.erb @@ -10,6 +10,6 @@ - <%= writing_conference.member_profile.name %> + <%= writing_conference.member_profile.name rescue "" %> <% end %> \ No newline at end of file