Created
May 3, 2020 03:18
-
-
Save anon987654321/a9be60bf9818cb436b6a3e129511f3fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit ab928ebc87d96dfa4f072de2f123cf9940f90f9a | |
Author: dev <[email protected]> | |
Date: Mon Mar 30 08:37:05 2020 +0200 | |
Add additional user fields to Devise HTML | |
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb | |
index 8ea5ea6..2f26dd2 100644 | |
--- a/app/views/devise/registrations/edit.html.erb | |
+++ b/app/views/devise/registrations/edit.html.erb | |
@@ -21,6 +21,27 @@ | |
<%= f.password_field :current_password, autocomplete: "current-password", placeholder: t("devise.passwords.current_password") %> | |
<p class="hint"><%= t "devise.registrations.we_need_your_password" %></p> | |
</div> | |
+ <div class="field"> | |
+ <%= f.text_field :first_name, placeholder: t("app.first_name") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :last_name, placeholder: t("app.last_name") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :city, placeholder: t("app.city") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :country, placeholder: t("app.country") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :hospital, placeholder: t("app.hospital") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :department, placeholder: t("app.department") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :role, placeholder: t("app.role") %> | |
+ </div> | |
<div class="field"> | |
<%= f.submit t("shared.submit"), class: "button primary" %> | |
</div> | |
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb | |
index 3666337..9f10e86 100644 | |
--- a/app/views/devise/registrations/new.html.erb | |
+++ b/app/views/devise/registrations/new.html.erb | |
@@ -13,6 +13,27 @@ | |
<div class="field"> | |
<%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: t("devise.passwords.confirm_password") %> | |
</div> | |
+ <div class="field"> | |
+ <%= f.text_field :first_name, placeholder: t("app.first_name") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :last_name, placeholder: t("app.last_name") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :city, placeholder: t("app.city") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :country, placeholder: t("app.country") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :hospital, placeholder: t("app.hospital") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :department, placeholder: t("app.department") %> | |
+ </div> | |
+ <div class="field"> | |
+ <%= f.text_field :role, placeholder: t("app.role") %> | |
+ </div> | |
<div class="field"> | |
<%= f.submit t("shared.submit"), class: "button primary" %> | |
</div> | |
diff --git a/config/locales/en.yml b/config/locales/en.yml | |
index 730bab3..7157f3d 100644 | |
--- a/config/locales/en.yml | |
+++ b/config/locales/en.yml | |
@@ -6,6 +6,16 @@ en: | |
app: | |
privacy: "Privacy" | |
database: "Database" | |
+ first_name: "First name" | |
+ last_name: "Last name" | |
+ city: "City" | |
+ country: "Country" | |
+ hospital: "Hospital" | |
+ department: "Department" | |
+ role: "Role" | |
+ status: "Status" | |
+ residence: "Residence" | |
+ latest_incidents: "Latest incidents" | |
shared: | |
new: "New" | |
edit: "Edit" | |
@@ -18,6 +28,14 @@ en: | |
# Devise | |
devise: | |
+ new_fields: | |
+ first_name: "First name" | |
+ last_name: "Last name" | |
+ city: "City" | |
+ country: "Country" | |
+ hospital: "Hospital" | |
+ department: "Department" | |
+ role: "Role" | |
shared: | |
email: "Email" | |
confirmations: | |
diff --git a/config/locales/nb.yml b/config/locales/nb.yml | |
index 76b4ebf..833e6a2 100644 | |
--- a/config/locales/nb.yml | |
+++ b/config/locales/nb.yml | |
@@ -6,6 +6,16 @@ nb: | |
app: | |
privacy: "Personvern" | |
database: "Database" | |
+ first_name: "Fornavn" | |
+ last_name: "Etternavn" | |
+ city: "By" | |
+ country: "Land" | |
+ hospital: "Sykehus" | |
+ department: "Departement" | |
+ role: "Rolle" | |
+ status: "Status" | |
+ residence: "Bosted" | |
+ latest_incidents: "Siste tilfeller" | |
shared: | |
new: "Ny" | |
edit: "Rediger" | |
@@ -18,6 +28,14 @@ nb: | |
# Devise | |
devise: | |
+ new_fields: | |
+ first_name: "Fornavn" | |
+ last_name: "Etternavn" | |
+ city: "By" | |
+ country: "Land" | |
+ hospital: "Sykehus" | |
+ department: "Departement" | |
+ role: "Rolle" | |
shared: | |
email: "Epost" | |
confirmations: | |
commit 201036eb0c37bb5233f4d328f69eaa33d5858032 | |
Author: dev <[email protected]> | |
Date: Mon Mar 30 08:24:09 2020 +0200 | |
Make Devise permit additional user fields | |
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb | |
index 09705d1..5d14ad3 100644 | |
--- a/app/controllers/application_controller.rb | |
+++ b/app/controllers/application_controller.rb | |
@@ -1,2 +1,9 @@ | |
class ApplicationController < ActionController::Base | |
+ before_action :configure_permitted_parameters, if: :devise_controller? | |
+ | |
+ protected | |
+ def configure_permitted_parameters | |
+ devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:email, :password, :first_name, :last_name, :city, :country, :hospital, :department, :role)} | |
+ devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:email, :password, :password_confirmation, :current_password, :first_name, :last_name, :city, :country, :hospital, :department, :role)} | |
+ end | |
end | |
commit 137174bc1d587ca168bca160dd1140c148e98dba | |
Author: dev <[email protected]> | |
Date: Mon Mar 30 08:15:36 2020 +0200 | |
Add additional database fields to user | |
rails generate migration AddAdditionalFieldsToUser first_name:string last_name:string city:string country:string hospital:string department:string role:string | |
diff --git a/db/migrate/20200401220926_add_additional_fields_to_user.rb b/db/migrate/20200401220926_add_additional_fields_to_user.rb | |
new file mode 100644 | |
index 0000000..e75da8c | |
--- /dev/null | |
+++ b/db/migrate/20200401220926_add_additional_fields_to_user.rb | |
@@ -0,0 +1,11 @@ | |
+class AddAdditionalFieldsToUser < ActiveRecord::Migration[6.0] | |
+ def change | |
+ add_column :users, :first_name, :string | |
+ add_column :users, :last_name, :string | |
+ add_column :users, :city, :string | |
+ add_column :users, :country, :string | |
+ add_column :users, :hospital, :string | |
+ add_column :users, :department, :string | |
+ add_column :users, :role, :string | |
+ end | |
+end | |
diff --git a/db/schema.rb b/db/schema.rb | |
index 0a471a0..d459a85 100644 | |
--- a/db/schema.rb | |
+++ b/db/schema.rb | |
@@ -10,7 +10,7 @@ | |
# | |
# It's strongly recommended that you check this file into your version control system. | |
-ActiveRecord::Schema.define(version: 2020_03_30_055533) do | |
+ActiveRecord::Schema.define(version: 2020_04_01_220926) do | |
create_table "users", force: :cascade do |t| | |
t.string "email", default: "", null: false | |
@@ -20,6 +20,13 @@ ActiveRecord::Schema.define(version: 2020_03_30_055533) do | |
t.datetime "remember_created_at" | |
t.datetime "created_at", precision: 6, null: false | |
t.datetime "updated_at", precision: 6, null: false | |
+ t.string "first_name" | |
+ t.string "last_name" | |
+ t.string "city" | |
+ t.string "country" | |
+ t.string "hospital" | |
+ t.string "department" | |
+ t.string "role" | |
t.index ["email"], name: "index_users_on_email", unique: true | |
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment