Skip to content

Commit

Permalink
Admin able to delete every other user except admins(feature)
Browse files Browse the repository at this point in the history
  • Loading branch information
gopesht committed Mar 9, 2014
1 parent e51cf14 commit ad544a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ def update
user.update_attributes!(params[:user])
redirect_to admin_users_path, :notice => "Updated #{user.email}"
end

def delete
@user = User.find(params[:id])
end

def destroy
@user = User.find(params[:id])
@user.destroy
redirect_to admin_users_path, :notice => "User got deleted"

end
end
7 changes: 7 additions & 0 deletions app/views/admin/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
%b Roles
%th
%th
%th
- @users.each do |user|
- person = Person.find_person_by_user_id(user.id)
%tr
Expand Down Expand Up @@ -71,6 +72,12 @@
"data-html" => "true",
"data-content" => user.popup_details,
"data-original-title" => ""
%td
- if current_user.id == user.id or user.role_ids.include? 3
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
- else
=link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger"
:javascript
$(document).ready(function() {
Expand Down

0 comments on commit ad544a1

Please sign in to comment.