Skip to content
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

Fix error ActiveModel::UnknownAttributeError: unknown attribute 'distributor' for Spree::Product on setup #7625

Closed
shen-sat opened this issue May 12, 2021 · 3 comments · Fixed by #7628

Comments

@shen-sat
Copy link
Contributor

What we should change and why (this is tech debt)

When running setup/script the above error pops up

Context

https://openfoodnetwork.slack.com/archives/C2GQ45KNU/p1620456501144500?thread_ts=1620397593.134200&cid=C2GQ45KNU
Linked issue: #7613

Impact and timeline

Timeline: 1 week. Impact: better onboarding experience for new developers ✨

@Matt-Yorkley
Copy link
Contributor

Matt-Yorkley commented May 12, 2021

Aha, I've never seen this before. Yeah it looks like a simple error in that sample data file. We just need to drop the distributor: keys from all the items in this array:

{
name: 'Garlic',
price: 20.00,
supplier: producers[0],
taxons: [vegetables],
distributor: distributors[0]

@viktorsmari
Copy link
Contributor

viktorsmari commented May 12, 2021

I can confirm removing the distributor lines fixed it for me when I tried it yesterday, however I thought these lines were needed, since they were added 2 years ago in commit 2019-01-08 4b389ba, and touched again in 2020-11-02 5289a5b

Maybe they were a forgotten part of a bigger change, since no one noticed the error they produced in a while.
Also, they don't error if you have already have the db with seeds on your computer, so that is probably why current devs have not noticed it.

viktorsmari added a commit to viktorsmari/openfoodnetwork that referenced this issue May 12, 2021
@Matt-Yorkley
Copy link
Contributor

they don't error if you have already have the db with seeds on your computer, so that is probably why current devs have not noticed it.

Yep! I think part of the issue is that previous versions of Rails used to silently ignore attributes that were not relevant, but after one of the Rails upgrades the behavior changed to throwing a fatal error instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants