From df97b18456fe7f59bb96172f705271342dbf68f4 Mon Sep 17 00:00:00 2001 From: manson Date: Tue, 15 Jul 2014 17:23:50 +0800 Subject: [PATCH] Fix url encode and rescue duration method in model --- app/controllers/admin/experiences_controller.rb | 6 +++--- app/models/experience.rb | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/experiences_controller.rb b/app/controllers/admin/experiences_controller.rb index d50af6e..10eb579 100644 --- a/app/controllers/admin/experiences_controller.rb +++ b/app/controllers/admin/experiences_controller.rb @@ -17,7 +17,7 @@ class Admin::ExperiencesController < OrbitMemberController @member = MemberProfile.find(experience_params['member_profile_id']) rescue nil @experience = Experience.new(experience_params) @experience.save - redirect_to '/admin/members/'+@member.to_param+'/Experience' + redirect_to URI.encode('/admin/members/'+@member.to_param+'/Experience') end def edit @@ -30,7 +30,7 @@ class Admin::ExperiencesController < OrbitMemberController @experience = Experience.find(params[:id]) @experience.update_attributes(experience_params) @experience.save - redirect_to '/admin/members/'+@member.to_param+'/Experience' + redirect_to URI.encode('/admin/members/'+@member.to_param+'/Experience') end def destroy @@ -66,7 +66,7 @@ class Admin::ExperiencesController < OrbitMemberController @intro = @intro.nil? ? ExperienceIntro.new({:member_profile_id=>@member.id}) : @intro @intro.update_attributes(intro_params) @intro.save - redirect_to '/admin/members/'+@member.to_param+'/Experience' + redirect_to URI.encode('/admin/members/'+@member.to_param+'/Experience') end def get_settings diff --git a/app/models/experience.rb b/app/models/experience.rb index ca90fb9..10b56bf 100644 --- a/app/models/experience.rb +++ b/app/models/experience.rb @@ -26,7 +26,11 @@ class Experience before_validation :add_http def duration - self.start_date.strftime('%Y.%m')+' ~ '+self.end_date.strftime('%Y.%m') + if !self.start_date.nil? or !self.end_date.nil? + self.start_date.strftime('%Y.%m')+' ~ '+self.end_date.strftime('%Y.%m') + else + "" + end end def slug_title