Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8833391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:46:08+00:00 2026-06-14T08:46:08+00:00

I am using Ruby on Rails v3.2.2 and MySQL. I would like to abstract

  • 0

I am using Ruby on Rails v3.2.2 and MySQL. I would like to “abstract” and “handle” geographical spaces in a balanced way, but I am in trouble when I have to “invent” the overall structure. So…

How to organize model classes and related database data for geographical spaces? That is, for example, which “type” of classes should I implement – should I use something like RoR Single Table Inheritance or Polymorphic classes? – ? and, given the mentioned model class (or model classes), which table columns should I add to my database and how should those be populated in order to be retrievable (reasons for this are that I am thinking to implement a search form in order to find records in an user friendly way, perhaps with a “autocompletable name” input field)?


Note: At this time, I am planning to “organize” a geographical space in (“nested” spaces) continents > countries > regions > cities > addresses. However, since retrievability for search form use cases, I am wondering to create one only database table in order to handle those space objects.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:46:09+00:00Added an answer on June 14, 2026 at 8:46 am

    It think that using belongs_to and has_many would be friendly enough, even for autocompletes and something else.

    class Continent < ActiveRecord::Base
        has_many :countries
    end 
    
    class Country < ActiveRecord::Base
        belongs_to :continent
        has_many :regions
    end
    
    class Region < ActiveRecord::Base
        belongs_to :country
        has_many :cities
    end
    

    Something like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Ruby on Rails 3.2.2 and MySQL. I have a method (an
I have a deployment using: rails 2.3.2 ruby 1.8.7 mysql db and 3 mongrel
I am using Ruby on Rails 3.2.2 and I would like to know if
I am using Ruby on Rails 3 and MySQL. In my project I would
I am using Ruby on Rails 3.2.2 and I would like to check the
I am using ruby on rails with a MySQL backend. I have a table
I am using Ruby on Rails 3.2.2 and MySQL. From the logger I know
I am reading (mysql) data to display on the view using ruby on rails.
I am using Ruby on Rails, but I think this question could be applied
I am using Ruby 1.9.2, the Ruby on Rails v3.2.2 gem and the MySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.