开发者

How do I use my rails3 generator in all my projects?

开发者 https://www.devze.com 2023-01-31 22:24 出处:网络
I wrote a generator that I\'d like to use in my Rails3 projects using Thor (which I absolutely love).

I wrote a generator that I'd like to use in my Rails3 projects using Thor (which I absolutely love).

How would I go about using my generator in all my rails3 projects? i.e. how do I install it?

If the answer is to make a gem out of it - could y开发者_开发技巧ou please describe the rails3 process of doing so?

Thanks!


Yep, make a gem!

In terms of loading your generator it's pretty much as simple as putting your generator files in lib/generators/#{generator_name}/ in the gem. See the generators guide for a little more explanation of how they're loaded.

Check out some gems which do this such as rails3-generators gem. rspec-rails, machinist for examples.

In terms of actually building your gem, check out jeweler

0

精彩评论

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