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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:09:58+00:00 2026-05-28T18:09:58+00:00

All of the tutorials I’ve seen so far for RoR have shown me generating

  • 0

All of the tutorials I’ve seen so far for RoR have shown me generating models like:

rails generate User name:string placeofbirth:string

This generates a class for the model, and only actually references an attribute if I apply a validation of some kind.

So my question is, how do I use a ‘code’ first approach when creating my models. Or is it the rails way to just right down on paper the attributes you want, run the generate command with each attribute you want and it’s type, then run the rake db:migrate command?

I’d love some more proven patterns on this subject because so far the way I’ve seen seems too empty.

  • 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-28T18:09:59+00:00Added an answer on May 28, 2026 at 6:09 pm

    Yes, this is the rails way- migration comes first and generates the code and the database- and the model class inspects the database to see what fields are there and make accessible via methods.

    You can do gem install annotate_models if you want to get some comments in your model class with the attribute names and types.

    See here for an example: https://github.com/ctran/annotate_models

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

Sidebar

Related Questions

All the tutorials I have seen seem to use *.jsf , *.faces , or
This is very dumb - but I've seen all the tutorials and guides -
When I first started reading about Python, all of the tutorials have you use
Django tutorials everywhere use constant-set application name all around - in urls file, in
In almost all tutorials of BackgroundWorker the reportProgress event is handled like this (this
All the tutorials I have done say that I set stuff to nil in
I don't know why but in all tutorials I've seen there is DBObject.TableObject.Add(newObject); .
I have read tutorials all over the web with different kinds of tutorials specified
I've been plowing through tutorials all day trying to install RMagick, and have gotten
I'm learning Eclipse PDT for PHP development. In pretty much all tutorials I've read

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.