Rails 4和模板保留字

Rails 4 and Template reserved word

我有一个 Rails 4 应用程序,我已经创建了一个模板模型。当我尝试从视图中的该模型获取一些数据时遇到问题,例如:

<%= Template.where(:key_name => 'email_layout').first.content %>

它说:

ActionView::Template::Error: undefined method `where' for ActionView::Template:Class

我能做什么?

提前致谢。

你可以直接使用

 ::Template.where(....)

和Rails会找到正确的模型。