teecraft
teecraft

Reputation: 927

Rails 3 - How do I build a database table with loads of data?

I'm incredibly new to Rails and programming in general. Built my first, fairly static, Rails app. I have 100's of products (specifically t-shirts) that all have associated colors (RGB values) and sizes that I need to display on several product pages.

Rather than hand-coding this information, I assume I need to build a database for it. If I create a Product model and products controller with the correct table headers, how do I get the data into the table?

Most of the documentation that I've been reading has to do with building tables that hold user-generated dynamic content, not large lists like the one I'm trying to create.

Thanks!

Upvotes: 1

Views: 370

Answers (2)

Trip
Trip

Reputation: 27114

Hey Teecraft, welcome to RoR.

Well you count as User-Generated Content as well. If you have a pre-existing database that you just need to migrate over, that's a different story. But it sounds like you're starting from scratch. Excuse me if I'm wrong.

To start from scratch, you should follow the tutorials.

Create your scaffold ( scaffolds are great for beginners ).

rails g scaffold Product productType:string color:int size:string
rake db:migrate

Then start trucking away at all that info. If you ever want to migrate to a new application, then you can easily mysqldump your db to a new app.

Upvotes: 0

Yannis
Yannis

Reputation: 5426

You probably need to seed your data in: http://www.agileweboperations.com/seed-data-in-ruby-on-rails/

Upvotes: 3

Related Questions