0

Sorry for the title but I can't find words to explain this exactly. I'm a bit confused in rails when I have to choose where should I place my external libraries.

For example, if I want to prepare a gem which will contain a lot of helpers that I can share across all my applications, what should it do? Should it install those helpers under my app/helpers dir?

Actually these are all directories I know where I could place external libraries:

  • vendor/assets
  • app/helpers
  • vendor/plugins [which has been deprecated if I'm not wrong]
  • lib/assets
  • lib/tasks

What if I want create a method that can be used in controllers if they include something, where should I place such a file?

If I create a gem that can be used in rails, where should it install files?

I'm a bit lost, I always create a file but I feel a bit uncomfortable because I always don't know where should I place it.

Edit 1:

I want to add also a special case, where do you place a library written in javascript which directory structure is hardly tied up toghether, so you can't move css/images into different directories. How do you handle this? I created a directory in vendor/assets to make it works, but I don't know if it's the best way to solve this issue.

4

1 回答 1

0

实际上阅读并获取有关 IRC 聊天的信息,我理解了这些事情:

  • vendor/assets 应该用于“完全”在 Rails 外部的库,例如与 C++ 库交互的东西或类似的东西。
  • app/helpers 用于仅对此应用程序有用的助手
  • 供应商/插件已被弃用
  • lib/assets 用于您想要使用的库(例如 javascript 库),您不希望将其存储在 gem 中(或不作为 gem 发布)。

这绝对不是一个完整的答案,但实际上是我找到的唯一一个。

关于宝石以及它们应该如何构建,我会提出一个新问题。

于 2012-11-12T16:09:26.707 回答