8 changed files with 70 additions and 14 deletions
@ -1,4 +1,10 @@
|
||||
class Users::AccountController < ApplicationController |
||||
def index; end |
||||
def personal_details; end |
||||
|
||||
def update |
||||
if current_user.update('name': params[:user][:name], 'email': params[:user][:email],) |
||||
redirect_to(users_account_path()) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,14 @@
|
||||
module AccountHelper |
||||
def resource_name |
||||
:user |
||||
end |
||||
|
||||
def resource |
||||
@resource = current_user |
||||
end |
||||
|
||||
def devise_mapping |
||||
@devise_mapping ||= Devise.mappings[:user] |
||||
end |
||||
end |
||||
|
@ -1,3 +1,23 @@
|
||||
<h1 class="govuk-heading-l"> |
||||
Personal details |
||||
</h1> |
||||
<% content_for :before_content do %> |
||||
<%= link_to 'Back', :back, class: "govuk-back-link" %> |
||||
<% end %> |
||||
|
||||
<%= form_for(resource, as: resource_name, url: account_update_path(), html: { method: :patch }) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<h1 class="govuk-heading-l">Change your personal details</h1> |
||||
|
||||
<div class="govuk-form-group"> |
||||
<%= f.label :name, class: "govuk-label" %> |
||||
<%= f.text_field :name, autocomplete: "name", class: "govuk-input" %> |
||||
</div> |
||||
|
||||
<div class="govuk-form-group"> |
||||
<%= f.label :email, class: "govuk-label" %> |
||||
<%= f.email_field :email, autocomplete: "email", class: "govuk-input" %> |
||||
</div> |
||||
|
||||
<%= f.submit "Save changes", class: "govuk-button" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
|
@ -0,0 +1,7 @@
|
||||
class AddNameEmailRoleOrgToUsers < ActiveRecord::Migration[6.1] |
||||
def change |
||||
add_column :users, :name, :string |
||||
add_column :users, :role, :string |
||||
add_column :users, :organisation, :string |
||||
end |
||||
end |
Loading…
Reference in new issue