Jump to content
  • 0

всегда ли нужна ли отдельная таблица?


cyklop77
 Share

Question

помогите пожалуйста разобраться в вопросе

 

наиболее логичная практика при добавления признака объекту это использование отдельной таблицы. например есть объект User. требуется добавить признак role. роли всего три: admin, manager, regular . далее обычно создаётся отдельная табличка в БД:

id      role_title0       admin1       manager2       regular

это логично и хорошо

 

но если признаков не много(например 2 или 3, как в описанном случае), то во многих туториалах советуется не использовать отдельную таблицу, а реализовать признаки средствами фреймворка. при этом модель приблизительно это выглядит так: 

f.input :role, as: :radio, collection: {Regular: "regular", Manager: "manager", Administrator: "admin"}

этот подход тоже рабочий, но стоит ли его использовать? всё таки это скорее плохая практика. какой подход вы предпочитаете использовать и почему, расскажите пожалуйста?

 

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy