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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:51:27+00:00 2026-05-19T16:51:27+00:00

I’ve generated four models in my Rails App and i now want to create

  • 0

I’ve generated four models in my Rails App and i now want to create the tables for the same models through the migrations.

The blanks migrations are sitting there in my /db/migrate folder, now, in what sequence will the Migrations run if i do rake db:migrate

And what should i do to ensure that my tables are generated properly. Should i go ahead and define the associations in my models and then run the migrations?

Because, if i run them as they are, how is Rails gonna figure out the t.references part of the Migrations??

Please help.

  • 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-05-19T16:51:27+00:00Added an answer on May 19, 2026 at 4:51 pm

    A migration is not directly linked to your model. Before running a migration, you don’t need to worry about putting stuff (e.g. associations) in the models or leaving them out. A migration is just a recipe to create or modify a database table and it’s fields/columns. You can sort out your model’s associations before or after running the migrations. It doesn’t matter.

    Migrations are run in the order of the filenames of your migrations. If you created your migrations via script/generate model YourModelName or script/generate migration MyMigration a timestamp (like 20110201165030 for example) is always prepended to the name of the file. That makes sure the migrations are run in the order you generated them.

    The t.references part doesn’t need to figure out anything. It only takes the symbol that comes next, makes it a string, appends _id and creates an integer field with that (new) name in your database table. It’s just a convention. It certainly does not look into your model for any associations.

    (The code examples given here are for Rails 2.3. If you’re using Rails 3, I think the generate commands are a bit different).

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the

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.