-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zad6 #264
base: master
Are you sure you want to change the base?
zad6 #264
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dzięki za rozwiązanie 👍 Niestety nie udało mi się odpalić aplikacji przez złe relacje pomiędzy Category
i Product
. Można też dodać seedy. Reszta wygląda ok 🎉
def change | ||
create_table :customers do |t| | ||
t.string :name, null: false | ||
t.string :mail, null: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
na poziomie bazy jest NULL CONSTRAINT na kolumnie mail
, ale nie ma walidacji w modelu Customer
- powinna się tam znaleźć żeby nie dostawać brzydkich błędów z bazy danych tylko błędy z modelu. 😉
@@ -0,0 +1,9 @@ | |||
class Product < ApplicationRecord | |||
belongs_to :customer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ta linia nie pozwala na stworzenie produktu, który nie ma jeszcze przypisanego customera. Można to poprawić w następujący sposób:
belongs_to :customer, optional: true
@@ -0,0 +1,9 @@ | |||
class Product < ApplicationRecord | |||
belongs_to :customer | |||
has_many :categories, through: :category_product |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.