开发者

Refinery CMS (Rails): Creating a plugin or plugins with multiple models and relationships

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开发者_Python百科 good example of a solution to a similar problem, I would be grateful.

Thank you for looking!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜