Commit b02e3996 authored by Sara Kuqi's avatar Sara Kuqi
Browse files

change type & delete users-admin

parent 890b333c
......@@ -64,6 +64,19 @@ class UsersController < ApplicationController
redirect_to users_url
end
def change
user = User.find(params[:id])
if user.type == "Chemist"
user.type = "Operator"
user.save
elsif user.type == "Operator"
user.type = "Chemist"
user.save
end
#user.save
flash[:success] = "Type changed"
redirect_to users_url
end
private
def user_params
......@@ -100,4 +113,6 @@ class UsersController < ApplicationController
redirect_to(root_url) unless current_user.admin?
end
end
......@@ -7,17 +7,15 @@
<li>
<%= gravatar_for user, size: 50 %>
<%= link_to user.name, user %>
(<%=user.type%>)<br>
<% if current_user.admin? && !current_user?(user) %>
| <%= link_to "delete", user, method: :delete,
<%= link_to "delete", user, method: :delete,
data: { confirm: "You sure?" } %>
<%end%>
<% if user.type =='Chemist'%>
|<%= link_to "change type", user.type == "Operator", method: :put, data: {confirm: "Are you sure?" }%>
<% end %>
</li>
| <%=link_to (user.type ? "change type" : "No"),
change_user_path(user), :action => 'solve', data: { confirm: "You sure?" } %>
<%end%>
</li>
<% end %>
</ul>
<%= will_paginate %>
<%= will_paginate %>
</div>
......@@ -37,6 +37,12 @@ Rails.application.routes.draw do
end
end
resources :users do
member do
get :change
end
end
resources :results do
post :sort
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment