Ayrad
Ayrad

Reputation: 4056

create a new model or use the user model?

In a rails application. If you have a User model and a post model and a user can post X number of times according to a plan.

Can I just modify the User object and add a plan_id to my user object or is it better to generate a new model called plan and associate it to a user?

Upvotes: 0

Views: 42

Answers (2)

Dave Newton
Dave Newton

Reputation: 160181

There's no good way to answer this without knowing specifics or the future.

  • Might users end up having multiple plans?
  • How frequently are the plans required?

A "user" is not a "plan". A user has a plan. There should be a plan model; how it is stored is a separate issue. It may not be worth over-thinking at this point, either.

Upvotes: 1

markusschwed
markusschwed

Reputation: 142

It depends on what informations you want to store for the plan.

In my opinion, you should add a Plan model and add an association. In that case, you can store all important informations about the plan itself in a Plan and use it to show them on the pricing page, as well.

But i guess, there is no "right" or "wrong" answer, just favorites. :)

Upvotes: 1

Related Questions