Fix url encode and rescue in duration

This commit is contained in:
manson 2014-07-15 15:34:51 +08:00
parent f93b778abd
commit 120ee02f0c
2 changed files with 8 additions and 4 deletions

View File

@ -17,7 +17,7 @@ class Admin::DiplomasController < OrbitMemberController
@member = MemberProfile.find(diploma_params['member_profile_id']) rescue nil @member = MemberProfile.find(diploma_params['member_profile_id']) rescue nil
@diploma = Diploma.new(diploma_params) @diploma = Diploma.new(diploma_params)
@diploma.save @diploma.save
redirect_to '/admin/members/'+@member.to_param+'/Diploma' redirect_to URI.encode('/admin/members/'+@member.to_param+'/Diploma')
end end
def edit def edit
@ -30,7 +30,7 @@ class Admin::DiplomasController < OrbitMemberController
@diploma = Diploma.find(params[:id]) @diploma = Diploma.find(params[:id])
@diploma.update_attributes(diploma_params) @diploma.update_attributes(diploma_params)
@diploma.save @diploma.save
redirect_to '/admin/members/'+@member.to_param+'/Diploma' redirect_to URI.encode('/admin/members/'+@member.to_param+'/Diploma')
end end
def destroy def destroy
@ -66,7 +66,7 @@ class Admin::DiplomasController < OrbitMemberController
@intro = @intro.nil? ? DiplomaIntro.new({:member_profile_id=>@member.id}) : @intro @intro = @intro.nil? ? DiplomaIntro.new({:member_profile_id=>@member.id}) : @intro
@intro.update_attributes(intro_params) @intro.update_attributes(intro_params)
@intro.save @intro.save
redirect_to '/admin/members/'+@member.to_param+'/Diploma' redirect_to URI.encode('/admin/members/'+@member.to_param+'/Diploma')
end end
def get_settings def get_settings

View File

@ -26,7 +26,11 @@ class Diploma
before_validation :add_http before_validation :add_http
def duration 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') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue "")
else
""
end
end end
def slug_title def slug_title