Question

My goal is to create a way for an admin to create two models in the Refinery admin: Campaigns and Videos

I would like to have it setup so that a Campaign has many Videos and that each Video belongs to a Campaign. Both Videos and Campaigns will have a title, description, and a preview image. I'm not certain of the best way to go about this. Is it possible to setup two plugins and form a relationship between the two? Or, should I create one plugin with both models. If someone could point me in the right direction or a good example of a solution to a similar problem, I would be grateful.

Thank you for looking!

Was it helpful?

Solution

A good example of what you're trying to do is the default pages plugin. That plugin contains two models: Page and PagePart. You could use that as a way to go.

However, if you think you would ever use one of the models but not the other in a different application, I would suggest building them as separate plugins, and then creating the association inside the rails app by overriding plugin functions. You can access any model that is registered with Rails from inside the other plugins.

Best of luck. Feel free to respond with other questions. We've just started using Refinery ourselves, and have been building plugins like mad.

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