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

can all attributes of a model be wrapped? #832

Open
cdesch opened this issue Jun 12, 2018 · 2 comments
Open

can all attributes of a model be wrapped? #832

cdesch opened this issue Jun 12, 2018 · 2 comments

Comments

@cdesch
Copy link

cdesch commented Jun 12, 2018

Is there a way to wrap all attributes of a model with a decorator? Similar to the way forms are wrapped with errors on the invalid form field, is there a conditional way to wrap each attribute being decorated with a error?

For example, in my model I have a data_results of jsonb which contains a json list of which attributes have errors as well as their descriptions of what the error messages are. If the there is an error present, I want to wrap that attribute on the show page with the error if it is present in the data_results.

I thought that a helper would be good for this possibility, but I'm not sure if draper should be doing this instead.

@Josh-Rosen
Copy link

@cdesch why not decorate the jsonb type class returned by calling model. data_results.decorate? Another option would be to decorate the result of data_results from your model.

@cdesch
Copy link
Author

cdesch commented Jul 30, 2018

Ah!. Let me give that a try. Thank you!

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