Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个方法“random_password”,我希望能够从我的 rails 3 项目中的多个模型中访问它。我只是想知道在哪里存储它以及如何提供对它的访问的约定是什么。任何帮助表示赞赏。
你需要一个模块。这是共享的,可供多个模型使用。它们通常放在 /lib 中。