fix for conference without name

This commit is contained in:
Harry Bomrah 2014-10-02 19:50:56 +08:00
parent b10d4153a1
commit 8f464a960d
2 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,7 @@
class Admin::WritingConferencesController < OrbitMemberController class Admin::WritingConferencesController < OrbitMemberController
layout "member_plugin" layout "member_plugin"
before_action :set_writing_conference, only: [:show, :edit , :update, :destroy]
before_action :set_plugin before_action :set_plugin
before_action :get_settings,:only => [:new, :edit, :setting] before_action :get_settings,:only => [:new, :edit, :setting]
@ -24,20 +25,17 @@ class Admin::WritingConferencesController < OrbitMemberController
end end
def edit def edit
@writing_conference = WritingConference.find(params[:id])
@member = @writing_conference.member_profile @member = @writing_conference.member_profile
end end
def update def update
@member = MemberProfile.find(conference_params['member_profile_id']) rescue nil @member = @writing_conference.member_profile
@writing_conference = WritingConference.find(params[:id])
@writing_conference.update_attributes(conference_params) @writing_conference.update_attributes(conference_params)
@writing_conference.save @writing_conference.save
redirect_to params['referer_url'] redirect_to params['referer_url']
end end
def destroy def destroy
@writing_conference = WritingConference.find(params[:id])
@writing_conference.destroy @writing_conference.destroy
end end
@ -84,6 +82,18 @@ class Admin::WritingConferencesController < OrbitMemberController
private 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 def conference_params
params.require(:writing_conference).permit! rescue nil params.require(:writing_conference).permit! rescue nil
end end

View File

@ -10,6 +10,6 @@
</ul> </ul>
</div> </div>
</td> </td>
<td><%= writing_conference.member_profile.name %></td> <td><%= writing_conference.member_profile.name rescue "" %></td>
</tr> </tr>
<% end %> <% end %>