psanchezp

Basic user forms

...@@ -118,7 +118,7 @@ table { ...@@ -118,7 +118,7 @@ table {
118 grid-template-columns: 2.5vw auto 2.5vw; 118 grid-template-columns: 2.5vw auto 2.5vw;
119 } 119 }
120 120
121 -.admin-index { 121 +.admin-index, .user-index, .user-form {
122 grid-row: 2; 122 grid-row: 2;
123 grid-column: 2; 123 grid-column: 2;
124 124
......
1 +class Admin::UsersController < CrudController::Base
2 + enable_gatekeeper
3 + guard_bifrost
4 +
5 + def update
6 + if update!
7 + redirect_to admin_users_path
8 + else
9 + render :edit
10 + end
11 + end
12 +
13 + private
14 +
15 + def object_params
16 + params.require(:user).permit(
17 + :name, :mail, :password, :password_confirmation
18 + )
19 + end
20 +end
1 +.user-form
2 + h2
3 + = "#{title} User"
4 + = simple_nested_form_for [:admin, @object] do |f|
5 + = f.input :name
6 + = f.input :mail
7 + = f.input :password
8 + = f.input :password_confirmation
9 + hr
10 + = f.submit 'Save'
11 +
12 +
1 += render 'form', title: 'Edit'
...\ No newline at end of file ...\ No newline at end of file
1 +.user-index
2 + h2
3 + | Users
4 + = link_to 'New User', new_admin_user_path, style: 'float: right'
5 +
6 + - attrs = %i[name mail]
7 + table
8 + thead
9 + - attrs.each do |a|
10 + th = User.human_attribute_name(a)
11 + th
12 + tbody
13 + - @object_collection.each do |model|
14 + tr
15 + - attrs.each do |a|
16 + td = model.send(a)
17 + td
18 + = link_to 'Edit', edit_admin_user_path(model)
19 +
20 +
1 += render 'form', title: 'New'
...\ No newline at end of file ...\ No newline at end of file
...@@ -11,5 +11,6 @@ Rails.application.routes.draw do ...@@ -11,5 +11,6 @@ Rails.application.routes.draw do
11 namespace :admin do 11 namespace :admin do
12 resources :pools 12 resources :pools
13 resources :groups 13 resources :groups
14 + resources :users
14 end 15 end
15 end 16 end
......