Skip to content

FEATURE: Can edit category/host relationships for embedding#1

Open
akshayutture-augment wants to merge 1 commit into
rest-serializer-enhancement-prefrom
rest-serializer-enhancement-post
Open

FEATURE: Can edit category/host relationships for embedding#1
akshayutture-augment wants to merge 1 commit into
rest-serializer-enhancement-prefrom
rest-serializer-enhancement-post

Conversation

@akshayutture-augment

@akshayutture-augment akshayutture-augment commented Nov 17, 2025

Copy link
Copy Markdown

No description provided.

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 4 suggestions posted.

Comment augment review to trigger a new review at any time.

end

def update
host = EmbeddableHost.where(id: params[:id]).first

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host can be nil here if an invalid id is passed; consider handling the not-found case (e.g., 404) to avoid a 500 from save_host.

🤖 Was this useful? React with 👍 or 👎

end

def destroy
host = EmbeddableHost.where(id: params[:id]).first

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as update: if host is nil, host.destroy will raise; consider returning a 404 or similar when the record isn’t found. (Related to the update action above.)

🤖 Was this useful? React with 👍 or 👎

belongs_to :category

before_validation do
self.host.sub!(/^https?:\/\//, '')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.host.sub! will raise if host is nil; guarding for presence before normalizing (or defaulting to an empty string) will prevent validation-time exceptions.

🤖 Was this useful? React with 👍 or 👎

host = uri.host
return false unless host.present?

where("lower(host) = ?", host).first

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query uses lower(host) = ? but doesn’t lowercase the bound value; using host.downcase (or lower(?)) avoids case-mismatch issues for mixed-case hosts.

🤖 Was this useful? React with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants