forked from saurabh/personal-lab
fix for lab without name
This commit is contained in:
parent
c6abf7ad6a
commit
84a0d966ed
|
@ -1,6 +1,7 @@
|
||||||
class Admin::LabsController < OrbitMemberController
|
class Admin::LabsController < OrbitMemberController
|
||||||
layout "member_plugin"
|
layout "member_plugin"
|
||||||
|
|
||||||
|
before_action :set_lab, 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::LabsController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = @lab.member_profile rescue nil
|
||||||
@lab = Lab.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = MemberProfile.find(lab_params['member_profile_id']) rescue nil
|
@member = @lab.member_profile rescue nil
|
||||||
@lab = Lab.find(params[:id])
|
|
||||||
@lab.update_attributes(lab_params)
|
@lab.update_attributes(lab_params)
|
||||||
@lab.save
|
@lab.save
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@lab = Lab.find(params[:id])
|
|
||||||
@lab.destroy
|
@lab.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,6 +79,18 @@ class Admin::LabsController < OrbitMemberController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_lab
|
||||||
|
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
|
||||||
|
@lab = Lab.find_by(:uid => uid) rescue Lab.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
def lab_params
|
def lab_params
|
||||||
params.require(:lab).permit! rescue nil
|
params.require(:lab).permit! rescue nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<%= link_to lab.lab_title, OrbitHelper.url_to_plugin_show(lab.to_param,'personal_lab'), target: "blank"%>
|
<%= link_to lab.lab_title, OrbitHelper.url_to_plugin_show(lab.to_param,'personal_lab'), 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/'+lab.member_profile.to_param+'/labs/'+lab.id+'/edit' %></li>
|
<li><%= link_to t('edit'), edit_admin_lab_path(lab) %></li>
|
||||||
<li><%= link_to t(:delete_), admin_lab_path(id: lab.id, member_profile_id: lab.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
<li><%= link_to t(:delete_), admin_lab_path(id: lab.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue