I'm feeling fairly seasoned in Ruby on Rails by now, and have attempted to build my own Rails plugins. Going through that process, however, I realized that I really have not found very many good resources that clearly spell out what the conventions are for creating Rails gems/plugins, and how to efficiently accomplish some of the things that I wanted to do with my plugin.
我现在对Ruby on Rails感觉相当老练,并试图构建我自己的Rails插件。然而,经历这个过程,我意识到我真的没有找到很多很好的资源,清楚地说明了创建Rails gems / plugins的惯例,以及如何有效地完成我想用我做的一些事情。插入。
It seems to me that the documentation for buildings Rails gems is not very good, but maybe I'm not looking in the right places. In an attempt to gain insight into how other gems are built, I've read through some of the source code of the Devise plugin for user authentication. I have found virtually nothing describing a procedure similar to how Devise injects its own methods into an existing model, even though this seems like it may be a very useful thing for a lot of good gems to do.
在我看来,建筑物Rails宝石的文档不是很好,但也许我不是在寻找合适的地方。为了深入了解其他宝石是如何构建的,我已经阅读了用于用户身份验证的Devise插件的一些源代码。我发现几乎没有任何描述类似于Devise如何将自己的方法注入到现有模型中的过程,尽管这似乎对许多好的宝石来说可能是非常有用的。
My question is this: Where should I go to learn how to build good Rails gems? Are there spelled out conventions for how to do certain things?
我的问题是:我应该去哪里学习如何构建好的Rails宝石?是否有关于如何做某些事情的约定?
3 个解决方案
#1
2
The currently popular method to do what you are trying to achieve is to use Engines. Engines basically let you mount one application inside another, allowing you to do anything from add a method or two, to adding a complete blog. The official guides have a very nice step-by-step guide to getting started, and there are many good unofficial guides, as well. An engine basically consists of a little bit of initialization code, the application code, and a dummy application for testing and development. It might look intimidating, at first, but it's much easier than it sounds, at first. Good luck
目前流行的方法是做你想要实现的目标是使用引擎。引擎基本上允许您将一个应用程序安装在另一个应用程序中,允许您通过添加一个或两个方法来执行任何操作,以添加完整的博客。官方指南有一个非常好的一步一步的入门指南,还有很多很好的非官方指南。引擎基本上由一些初始化代码,应用程序代码和用于测试和开发的虚拟应用程序组成。起初它可能看起来令人生畏,但起初它比听起来要容易得多。祝你好运
#2
1
Here is the most modern approach to gem crafting with Bundler:
这是使用Bundler进行宝石制作的最现代化方法:
bundle gem your_gem
cd your_gem
edit your_gem.gemspec and add description, summary and optional website. Add required gems such as rspec to the Gemfile.
编辑your_gem.gemspec并添加说明,摘要和可选网站。将所需的gems(如rspec)添加到Gemfile中。
rspec --init
touch spec/your_gem_spec.rb
Write good tests. Add your code to lib/your_gem.rb. When you're finished its time to build and push to rubygems.org:
写出好的测试。将您的代码添加到lib / your_gem.rb。当你完成构建并推送到rubygems.org时:
gem build your_gem.gemspec
gem push your_gem-0.0.1.gem
And thats it. Next time you make a change be sure to change the version number in version.rb.
就是这样。下次进行更改时,请务必更改version.rb中的版本号。
#3
0
see below link that will help you how to build a good rails gem
请参阅下面的链接,它将帮助您构建一个好的rails gem
制作宝石
#1
2
The currently popular method to do what you are trying to achieve is to use Engines. Engines basically let you mount one application inside another, allowing you to do anything from add a method or two, to adding a complete blog. The official guides have a very nice step-by-step guide to getting started, and there are many good unofficial guides, as well. An engine basically consists of a little bit of initialization code, the application code, and a dummy application for testing and development. It might look intimidating, at first, but it's much easier than it sounds, at first. Good luck
目前流行的方法是做你想要实现的目标是使用引擎。引擎基本上允许您将一个应用程序安装在另一个应用程序中,允许您通过添加一个或两个方法来执行任何操作,以添加完整的博客。官方指南有一个非常好的一步一步的入门指南,还有很多很好的非官方指南。引擎基本上由一些初始化代码,应用程序代码和用于测试和开发的虚拟应用程序组成。起初它可能看起来令人生畏,但起初它比听起来要容易得多。祝你好运
#2
1
Here is the most modern approach to gem crafting with Bundler:
这是使用Bundler进行宝石制作的最现代化方法:
bundle gem your_gem
cd your_gem
edit your_gem.gemspec and add description, summary and optional website. Add required gems such as rspec to the Gemfile.
编辑your_gem.gemspec并添加说明,摘要和可选网站。将所需的gems(如rspec)添加到Gemfile中。
rspec --init
touch spec/your_gem_spec.rb
Write good tests. Add your code to lib/your_gem.rb. When you're finished its time to build and push to rubygems.org:
写出好的测试。将您的代码添加到lib / your_gem.rb。当你完成构建并推送到rubygems.org时:
gem build your_gem.gemspec
gem push your_gem-0.0.1.gem
And thats it. Next time you make a change be sure to change the version number in version.rb.
就是这样。下次进行更改时,请务必更改version.rb中的版本号。
#3
0
see below link that will help you how to build a good rails gem
请参阅下面的链接,它将帮助您构建一个好的rails gem
制作宝石