Add user page to admin panel, improve other admin pages #88
@ -1,4 +1,5 @@
|
||||
class Admin::UsersController < Admin::BaseController
|
||||
before_action :set_user, only: [:show]
|
||||
before_action :set_current_section
|
||||
|
||||
def index
|
||||
@ -12,8 +13,16 @@ class Admin::UsersController < Admin::BaseController
|
||||
}
|
||||
|
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_user
|
||||
address = params[:address].split("@")
|
||||
@user = User.where(cn: address.first, ou: address.last).first
|
||||
end
|
||||
|
||||
def set_current_section
|
||||
@current_section = :users
|
||||
end
|
||||
|
||||
6
app/views/admin/users/show.html.erb
Normal file
6
app/views/admin/users/show.html.erb
Normal file
@ -0,0 +1,6 @@
|
||||
<%= render HeaderComponent.new(title: "User: #{@user.address}") %>
|
||||
|
||||
<%= render MainSimpleComponent.new do %>
|
||||
<section>
|
||||
</section>
|
||||
<% end %>
|
||||
@ -39,7 +39,7 @@ Rails.application.routes.draw do
|
||||
|
||||
namespace :admin do
|
||||
root to: 'dashboard#index'
|
||||
resources 'users', only: ['index']
|
||||
resources 'users', param: 'address', only: ['index', 'show'], constraints: { address: /.*/ }
|
||||
|
galfert
commented
What's the What's the `constraints` for? Doesn't the regex basically allow anything?
raucao
commented
It's to prevent Rails from parsing out the part behind the dot character as a format type. It would otherwise regard e.g. the "org" in "user@kosmos.org" as format "org". It's to prevent Rails from parsing out the part behind the dot character as a format type. It would otherwise regard e.g. the "org" in "user@kosmos.org" as format "org".
|
||||
get 'invitations', to: 'invitations#index'
|
||||
resources :donations
|
||||
get 'lightning', to: 'lightning#index'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user
Isn't this creating a new DB
COUNTquery? Since the@usersare already there, wouldn't a@users.pending.sizebe more performant?@usersis not filtered by pending at that point, so.pendingwould actually create a query that selects all fields from the table using that filter, and then.sizewould convert the results into an array and count the contained items I believe. So.countshould be more performant if that is correct.