Skip to content

Commit

Permalink
chnages added: new+save, has many asso for extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Sepehr Behmanesh Fard committed Apr 23, 2024
1 parent 591bc3f commit 3a398b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def create
return
end

# Create a new user with the given email
new_user = User.create(email: email)
# Build a new user object with the given email
new_user = User.new(email: email)

if new_user.persisted?
if new_user.save
render json: { message: 'User created successfully', user: new_user }, status: :created
else
render json: { message: 'Failed to create user', errors: new_user.errors.full_messages }, status: :unprocessable_entity
Expand Down
3 changes: 1 addition & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ class User < ApplicationRecord
# Associasions
has_many :lms_credentials, dependent: :destroy
has_many :user_to_courses
has_many :lms_credentials
has_one :extensions
has_many :extensions
end

0 comments on commit 3a398b5

Please sign in to comment.