Skip to content

Commit e845dcc

Browse files
committed
feature/Add bio and location to users
1 parent 8c8edd2 commit e845dcc

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class ApplicationController < ActionController::Base
88
def configure_permitted_parameters
99
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password)}
1010

11-
devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :password, :current_password)}
11+
devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :bio, :location, :password, :current_password)}
1212
end
1313
end

app/controllers/registrations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class RegistrationsController < Devise::RegistrationsController
22
def update
3-
if current_user.update(sign_up_params)
3+
if current_user.update(account_update_params)
44
render json: { message: "Profile updated" }
55
else
66
render json: { message: "Failed to update profile" }, status: 400

app/javascript/edit-profile.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import EditAvatar from './edit-avatar';
2222
import FormField from './form-field';
2323
2424
import usersMixin from './mixins/usersMixin';
25+
import { EventBus } from './event-bus.js';
2526
2627
export default {
2728
components: { EditAvatar, FormField },
@@ -32,8 +33,8 @@ export default {
3233
return {
3334
userParams: {
3435
name: this.currentUser.name,
35-
bio: 'Dummy bio',
36-
location: 'Cambridge UK'
36+
bio: this.currentUser.bio,
37+
location: this.currentUser.location
3738
}
3839
}
3940
},
@@ -45,14 +46,13 @@ export default {
4546
4647
methods: {
4748
saveForm() {
48-
console.log('params', this.userParams)
49-
5049
this.updateUser(this.userParams)
5150
.then(res => {
52-
console.log('aya', res)
51+
EventBus.$emit('presentToast', res.data.message)
5352
})
5453
.catch(error => {
5554
console.error(error)
55+
EventBus.$emit('presentToast', error.response.data.message)
5656
})
5757
}
5858
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class AddBioAndLocationToUsers < ActiveRecord::Migration[6.0]
2+
def change
3+
add_column :users, :bio, :string, default: ''
4+
add_column :users, :location, :string, default: ''
5+
end
6+
end

db/schema.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2020_05_31_082400) do
13+
ActiveRecord::Schema.define(version: 2020_06_21_112744) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -81,6 +81,8 @@
8181
t.datetime "remember_created_at"
8282
t.datetime "created_at", precision: 6, null: false
8383
t.datetime "updated_at", precision: 6, null: false
84+
t.string "bio", default: ""
85+
t.string "location", default: ""
8486
t.index ["email"], name: "index_users_on_email", unique: true
8587
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
8688
end

0 commit comments

Comments
 (0)