2015-01-13 103 views
-2

在我看来,我使用类似另一种方式来呈现all_each做

= Services.all_each do |f| 
    %p f.somesthing 

我觉得这是不是最好的解决方案。 需要它在我的所有页面在边栏。

有没有其他方法可以做到这一点?

+0

是什么Services.all返回?一个什么样的数组? – tebayoso

回答

0

如果您想使视图具有这些共同点,请使用偏分量。

= Services.all_each do |f| 
    = render "path", f: f 

'path'在这里必须是完整路径或相对名称为'_path.html.haml'。

'_path.html.haml' 必须包含通用代码为

%,P = f.something

相关问题