Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Akilah Jones
Akilah Jones
18,397 Points

ActiveRecord: What is the rationale behind creating a table but not a corresponding model?

I'm currently taking the ActiveRecords course and I thought I'd grasped the difference between using:

  • rails generate model
  • rails generate migration

I thought "generate model" was used when you wanted to create a table (CREATE TABLE...) in the database and "generate migration" was used when you wanted to change a table (ALTER TABLE...) in the database.

However towards the end of STAGE 2, the instructor creates a table but there is no corresponding model.

Is it safe to assume that if a table only contains "relationship ids", then it doesn't need to have a corresponding model?

Any insight?

AJ

1 Answer

Binary Soul
Binary Soul
4,592 Points

i havent watched this course right now. But it really sounds like a "join table". Maybe this might help you! If im right about that, so you dont need an extra model for that, because it is managed with the "has_(many/one)"-relationship-operators in rails.