我有一个问题
应用程序/模型/关切/ map_scope.rb
module MapScope
extend ActiveSupport::Concern
included do
def map_scope(string_to_map)
#some mapping logic happens here
return string_to_map
end
end
end
应用程序/视图/客户/ index.html.erb
<table>
<thead>
<tr>
<th>ID</th>
<th>Scope</th>
</tr>
</thead>
<tbody>
<% @customers.each do |customer| %>
<tr>
<td><%= customer.id %></td>
<td>
<%= map_scope(customer.scope_name) %>
</td>
</tr>
<% end %>
</tbody>
</table>
我无法使下面的行工作,因为我需要映射表格中的每一行
<%= map_scope(customer.scope_name) %>
错误:undefined method map_scope' for #<#< Class..
如何在不使用应用程序控制器的情况下使map_scope函数可用于视图中?