Question

I'm creating a custom engine in refinery cms and I have a field called "PDF" that is a refinery resource field type.

Some entries in the engine will only have one pdf, while others will have multiple pdf's. Is there a way to do this without creating a bunch of extra fields that I don't need?

I'd prefer to loop through one pdf field rather than code extra fields into my engine - pdf_1:resource, pdf_2:resource, pdf_3:resource, pdf_4:resource, pdf_5:resource, etc.

How would you do this?

Was it helpful?

Solution

To the best of my knowledge there isn't a built-in Refinery process for this. has_many would be the way I would approach the problem.

OTHER TIPS

Would this be the right approach?

Create a new model for the pdf that belongs to my_custom_engine and use my_custom_engine has_many pdfs. Then use accepts_nested_attributes and some javascript on the admin view to add photos to each my_custom_engine entry. Pretty much like this:

http://railscasts.com/episodes/196-nested-model-form-revised?autoplay=true

I guess that's basic rails stuff, but I wanted to make sure there's not a way to do this built into refinery already.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top