fix for experience without name
This commit is contained in:
parent
8aa42bd5a1
commit
3ee52f175e
|
@ -1,6 +1,7 @@
|
|||
class Admin::ExperiencesController < OrbitMemberController
|
||||
layout "member_plugin"
|
||||
|
||||
before_action :set_experience, only: [:show, :edit , :update, :destroy]
|
||||
before_action :set_plugin
|
||||
before_action :get_settings,:only => [:new, :edit, :setting]
|
||||
|
||||
|
@ -24,20 +25,17 @@ class Admin::ExperiencesController < OrbitMemberController
|
|||
end
|
||||
|
||||
def edit
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@experience = Experience.find(params[:id])
|
||||
@member = @experience.member_profile rescue nil
|
||||
end
|
||||
|
||||
def update
|
||||
@member = MemberProfile.find(experience_params['member_profile_id']) rescue nil
|
||||
@experience = Experience.find(params[:id])
|
||||
@member = @experience.member_profile rescue nil
|
||||
@experience.update_attributes(experience_params)
|
||||
@experience.save
|
||||
redirect_to params['referer_url']
|
||||
end
|
||||
|
||||
def destroy
|
||||
@experience = Experience.find(params[:id])
|
||||
@experience.destroy
|
||||
end
|
||||
|
||||
|
@ -82,6 +80,18 @@ class Admin::ExperiencesController < OrbitMemberController
|
|||
|
||||
private
|
||||
|
||||
def set_experience
|
||||
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
|
||||
@experience = Experience.find_by(:uid => uid) rescue Experience.find("53c4fd3548345219f04c0000")
|
||||
end
|
||||
|
||||
def experience_params
|
||||
params.require(:experience).permit! rescue nil
|
||||
end
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<%= link_to experience.organizationt_title, OrbitHelper.url_to_plugin_show(experience.to_param,'personal_experience'), target: "blank"%>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t('edit'), '/admin/members/'+experience.member_profile.to_param+'/experiences/'+experience.id+'/edit' %></li>
|
||||
<li><%= link_to t(:delete_), admin_experience_path(id: experience.id, member_profile_id: experience.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
||||
<li><%= link_to t('edit'), edit_admin_experience_path(experience) %></li>
|
||||
<li><%= link_to t(:delete_), admin_experience_path(id: experience.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue