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 8194927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:58:20+00:00 2026-06-07T04:58:20+00:00

Using Rails 3.2.2 and ruby 1.9.3dev and mysql I am new to ruby and

  • 0

Using Rails 3.2.2 and ruby 1.9.3dev and mysql

I am new to ruby and rails. We have an existing database with a couple hundred tables. We would like to try out rails to see if it would be a positive change from PHP & ZendFramework.

Migrating data into another database is not an option for us because we have several other applications currently using this database. We wanted to “attach” a rails project to the existing database.

The part I am struggling is generating all the models from our existing database.

I seen a couple of older posts talking about some automated techniques including Magic Model Generator. While others talked about there is no way to do this, or you just have create them all manually.

I was not successful in generating models using Magic Model Generator (perhaps rails 2 only?)

Long ago, when we switched to ZendFramework, I wrote a quick script to analyze the database and generate all the model files for us. It would seem this would be a somewhat common scenario.

Note: We use ID instead of id and many have many foreign_key relationships.

So I wanted to ask the community what is the best (way/practice) to handle this?

  • 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-07T04:58:23+00:00Added an answer on June 7, 2026 at 4:58 am

    It’s not that difficult, just takes a bit more configuration. Here’s a basic template for a model:

    class YourIdealModelName < ActiveRecord::Base
      self.table_name = `actual_table_name`
      self.primary_key = `ID`
    
      belongs_to :other_ideal_model, 
        :foreign_key => 'foreign_key_on_other_table'
    
      has_many :some_other_ideal_models, 
        :foreign_key => 'foreign_key_on_this_table', 
        :primary_key => 'primary_key_on_other_table'
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a deployment using: rails 2.3.2 ruby 1.8.7 mysql db and 3 mongrel
i would like to deploy my ruby on rails website. I am using rails
I have a Ruby on Rails page that loads another page using jquery. I
I'm new to Ruby on Rails, looking at using it for an app that
Is it possible to detect an iPad 3 (aka The new iPad) using ruby/rails?
New to rails/ruby (using rails 3 and ruby 1.9.2), and am trying to get
says if i develop a Ruby on Rails application using Rails 2.3.2, will that
Using Rails 3.1.3 with Ruby 1.9.3p0. I've discovered that by default, Rails does not
Using Rails 3.1.3 and Ruby 1.9.3. I want to give the user a list
I am using: rails 2.3.5 ruby 1.8.7 and Windows 7 Home Basic I was

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.