psanchezp

Basic user forms

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