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.
我的 rails 应用程序中几乎没有静态页面(Contacts、、About us等)。通过分离路由(namespace :admin do ...)实现的管理界面。如何仅从管理界面管理静态页面中的静态(!)内容?谢谢
Contacts
About us
namespace :admin do ...
我建议使用像 Ryan Bates' cancan或 elabs' pundit这样的授权解决方案。 在那里,您可以轻松地为仅管理员用户定义关于:admin命名空间中的 restful 操作的能力。
:admin
然后,您可以根据需要使用 Ruby 的File类(1.9.3或2.0的文档)来操作文件(仅当用户是管理员时)。
File
但请注意缓存机制: 如果您正在缓存这些文件(例如,在您的服务器上 nginx、unicorn 或缓存解决方案,例如 varnish、squid),则必须将它们从缓存中清除,以便您可以查看更改。