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