开发者

How to create files from template in rails lib directory?

开发者 https://www.devze.com 2023-03-11 00:28 出处:网络
I am writing a gem and to use it, some directories, ruby classes and yaml files should be created in rails lib directory. I\'d like to have a scaffold method, which creates appropriate files with basi

I am writing a gem and to use it, some directories, ruby classes and yaml files should be created in rails lib directory. I'd like to have a scaffold method, which creates appropriate files with basic information, that will be modified later. How should I do this?

Should I add something to 'script' directory or to 'script/generate'? Where to store templates? Just for convenience I was using temporary solution: ruby script that creates files and then ju开发者_开发问答st puts content as strings line by line, but I don't like it at all and it doesn't seem much a ruby way...

Thanks for any suggestions.


Check out the Rails Guide on Generators.

They use the gem Thor under the hood.

0

精彩评论

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