Skip to content

Commit

Permalink
feat(user): add user name (#39)
Browse files Browse the repository at this point in the history
* Add user name

and update the app in necessary places

* feat(user) some changes

* feat(user): change mailer parameters

* feat(user): use select, fix tests
  • Loading branch information
andreybakanovsky committed Aug 30, 2023
1 parent 15c1beb commit b5b8170
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ AllCops:
Style/Documentation:
Description: Document classes and non-namespace modules.
Enabled: false

Metrics/BlockLength:
Exclude:
- "db/**/*"
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ class User < ApplicationRecord
:recoverable, :rememberable, :validatable

belongs_to :account, optional: true

validates :name, allow_blank: true, length: { minimum: 2, maximum: 20 }
end
2 changes: 1 addition & 1 deletion app/views/my_accounts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= account.name %>
<%= [current_user.name, account.email].select(&:present?).join(" ") %>
<br>
Account balance: <%= account.balance %>
<br>
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20230829201037_add_name_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddNameToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :name, :string
end
end
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.bigint "account_id"
t.string "name"
t.index ["account_id"], name: "index_users_on_account_id"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
Expand Down

0 comments on commit b5b8170

Please sign in to comment.