Skip to content

feat(organizations): add location column to database and model valida…#7563

Open
naman79820 wants to merge 1 commit into
CircuitVerse:masterfrom
naman79820:feat/add-org-location-db
Open

feat(organizations): add location column to database and model valida…#7563
naman79820 wants to merge 1 commit into
CircuitVerse:masterfrom
naman79820:feat/add-org-location-db

Conversation

@naman79820

@naman79820 naman79820 commented Jun 25, 2026

Copy link
Copy Markdown
Member

Fixes #7562

Describe the changes you have made in this PR -

This PR introduces the database and model foundation for adding a "Location" field to Organizations.

  • Added a database migration (add_location_to_organizations) to include a location string column in the organizations table, with an unless column_exists? guard for safety.
  • Updated db/schema.rb.
  • Added a validation rule in app/models/organization.rb to ensure location is no longer than 100 characters, while allowing it to be blank since it is an optional field (validates :location, length: { maximum: 100 }, allow_blank: true).
    (Note: The controller parameters will be added in controller pr).

Screenshots of the UI changes (If any) -


Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:
The code solves the problem of Organizations lacking a geographical location field by extending the organizations database schema.
I chose a standard string column rather than a complex geolocation object since the intent is just to display a simple text representation (e.g., "San Francisco, CA" or "India"). I added allow_blank: true to the model validation alongside the 100-character max limit to ensure that blank submissions do not trigger length validation errors, preventing unwanted ActiveRecord exceptions during form submission.


Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

Note: Please check Allow edits from maintainers if you would like us to assist in the PR.

Summary by CodeRabbit

  • New Features

    • Organizations now support an optional location field.
    • You can save location as part of organization details.
  • Bug Fixes

    • Added a validation to restrict location to a maximum length of 100 characters, while still allowing it to be left blank.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bae718a4-1cb6-44d2-a5a0-54813b92e567

📥 Commits

Reviewing files that changed from the base of the PR and between 8ad9c73 and 9390d0f.

📒 Files selected for processing (3)
  • app/models/organization.rb
  • db/migrate/20260625102515_add_location_to_organizations.rb
  • db/schema.rb
✅ Files skipped from review due to trivial changes (2)
  • db/migrate/20260625102515_add_location_to_organizations.rb
  • db/schema.rb
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/models/organization.rb

Walkthrough

Adds a location string column to organizations through a conditional migration and updates db/schema.rb to match. Organization now validates location with a maximum length of 100 characters while allowing blank values.

Suggested labels

potential-ai-slop

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: adding organization location support in the database and model validation.
Linked Issues check ✅ Passed The PR adds the requested location column and 100-char blank-allowed validation; controller permitting is explicitly deferred to a separate PR.
Out of Scope Changes check ✅ Passed The changes stay focused on organization location support and do not introduce unrelated edits.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
db/migrate/20260625102515_add_location_to_organizations.rb (1)

3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: use native if_not_exists instead of a manual guard.

Rails supports add_column's if_not_exists: true option, which avoids a separate column_exists? round-trip and keeps the guard atomic with the DDL.

♻️ Proposed simplification
-    add_column :organizations, :location, :string unless column_exists?(:organizations, :location)
+    add_column :organizations, :location, :string, if_not_exists: true

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 546b8fda-070d-4c8b-a01c-719ad88512fc

📥 Commits

Reviewing files that changed from the base of the PR and between c2cc280 and 8ad9c73.

📒 Files selected for processing (3)
  • app/models/organization.rb
  • db/migrate/20260625102515_add_location_to_organizations.rb
  • db/schema.rb

Comment thread db/schema.rb Outdated
@naman79820 naman79820 force-pushed the feat/add-org-location-db branch from 8ad9c73 to 9390d0f Compare June 25, 2026 10:37
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.

Feature: Add location field to Organizations

2 participants