fix for research without name
This commit is contained in:
parent
f92689293e
commit
e049ca73cf
|
@ -1,6 +1,7 @@
|
|||
class Admin::ResearchsController < OrbitMemberController
|
||||
layout "member_plugin"
|
||||
|
||||
before_action :set_research, only: [:show, :edit , :update, :destroy]
|
||||
before_action :set_plugin
|
||||
before_action :get_settings,:only => [:new, :edit, :setting]
|
||||
|
||||
|
@ -24,20 +25,17 @@ class Admin::ResearchsController < OrbitMemberController
|
|||
end
|
||||
|
||||
def edit
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@research = Research.find(params[:id])
|
||||
@member = @research.member_profile rescue nil
|
||||
end
|
||||
|
||||
def update
|
||||
@member = MemberProfile.find(research_params['member_profile_id']) rescue nil
|
||||
@research = Research.find(params[:id])
|
||||
@member = @research.member_profile rescue nil
|
||||
@research.update_attributes(research_params)
|
||||
@research.save
|
||||
redirect_to params['referer_url']
|
||||
end
|
||||
|
||||
def destroy
|
||||
@research = Research.find(params[:id])
|
||||
@research.destroy
|
||||
end
|
||||
|
||||
|
@ -81,6 +79,18 @@ class Admin::ResearchsController < OrbitMemberController
|
|||
|
||||
private
|
||||
|
||||
def set_research
|
||||
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
|
||||
@research = Research.find_by(:uid => uid) rescue Research.find(params[:id])
|
||||
end
|
||||
|
||||
def research_params
|
||||
params.require(:research).permit! rescue nil
|
||||
end
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
<%= link_to research.research_title, OrbitHelper.url_to_plugin_show(research.to_param,'personal_research'), target: "blank"%>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t('edit'), '/admin/members/'+research.member_profile.to_param+'/researchs/'+research.id+'/edit' %></li>
|
||||
<li><%= link_to t(:delete_), admin_research_path(id: research.id, member_profile_id: research.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
||||
<li><%= link_to t('edit'), edit_admin_research_path(research) %></li>
|
||||
<li><%= link_to t(:delete_), admin_research_path(id: research.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= research.member_profile.name %></td>
|
||||
<td><%= research.member_profile.name rescue "" %></td>
|
||||
</tr>
|
||||
<% end %>
|
Loading…
Reference in New Issue