为Rails应用程序构建扩展框架 [英] Building an extension framework for a Rails app

查看:103
本文介绍了为Rails应用程序构建扩展框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始研究为Rails应用程序构建用户级插件系统(如Wordpress插件)所需的条件,因此,我希望能获得一些一般性的指导/建议.通过用户级插件,我的意思是用户可以将其提取到一个文件夹中并将其显示在管理界面上,从而允许他们添加一些额外的配置然后激活它.

I'm starting research on what I'd need in order to build a user-level plugin system (like Wordpress plugins) for a Rails app, so I'd appreciate some general pointers/advice. By user-level plugin I mean a package a user can extract into a folder and have it show up on an admin interface, allowing them to add some extra configuration and then activate it.

执行此操作的最佳方法是什么?还有其他开源项目吗? Rails本身已经为可利用的程序员级插件提供了什么?有任何Rails插件可以帮助我解决这个问题吗?

What is the best way to go about doing this? Is there any other opensource project that does this already? What does Rails itself already offer for programmer-level plugins that could be leveraged? Any Rails plugins that could help me with this?

一个插件必须能够:

  • 运行自己的迁移(使用 (未记录)
  • 可以访问我的模型(插件已经可以使用)
  • 具有用于向视图添加内容的入口点(可以通过
  • run its own migrations (with this? it's undocumented)
  • have access to my models (plugins already do)
  • have entry points for adding content to views (can be done with content_for and yield)
  • replace entire views or partials (how?)
  • provide its own admin and user-facing views (how?)
  • create its own routes (or maybe just announce its presence and let me create the routes for it, to avoid plugins stepping on each other's toes)

我还有什么想念的吗?

还有,有没有一种方法可以限制插件可以访问涉及迁移和模型的表/动作,并且还可以限制它们对路由的访问(也许让它们包括但不删除路由)?

Also, is there a way to limit which tables/actions the plugin has access to concerning migrations and models, and also limit their access to routes (maybe letting them include, but not remove routes)?

P.S .:我将尝试保持此更新,编译我发现的内容和相关答案,以便为他人提供某种指导.

推荐答案

您可能想查看 mephisto ,这是一个使用ruby on rails构建的博客软件,并具有附加插件支持.不确定您的想法是否可行,但可能会给您一些很好的见识.可以在 GitHub 上找到该源.

You might want to check out mephisto, it's a blogging software built with ruby on rails and has add-on plugin support. Not sure if it works how you are thinking of, but might give you some good insights. The source can be found on GitHub.

这篇关于为Rails应用程序构建扩展框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆