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

Graceful error display on non-existent belongs_to association. #33

Closed
elvinaspredkelis opened this issue Mar 1, 2021 · 3 comments
Closed

Comments

@elvinaspredkelis
Copy link

When adding a reference to a model, I personally make an initial migration allowing null values for the model_id, fill the ids and only then force the null: false on the id column.

However, this causes a NoMethodError on the display_name of a column. It is absolutely reasonable, but it makes the resource completely unavailable in that intermediate stage.

ActionView::Template::Error (undefined method `display_name' for nil:NilClass):
    1: <% object = field.value(record) %>
    2: <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object) %>

Perhaps it would make sense to somehow handle this use case?

@excid3 excid3 closed this as completed in 2222b4a Mar 1, 2021
@excid3
Copy link
Owner

excid3 commented Mar 1, 2021

@elvinaspredkelis Try out master and see if that fixes it for ya. We had the correct check in the other field types, but not belongs_to!

If that fixes it, I'll cut a new release.

@elvinaspredkelis
Copy link
Author

@excid3

Awesome, looks like the master branch fixed it. Thanks!

@excid3
Copy link
Owner

excid3 commented Mar 4, 2021

Alrighty, released as 1.0.1 🔥

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

No branches or pull requests

2 participants