刘华佼的全栈学习记录

如何使用自定义的Helper

| Comments

目标

使用自定义的Helper

步骤一:自制render_xxx_description(xxx)

在app/helpers/xxxs_helper.rb中加入:

module xxxsHelper
  def render_xxx_description(xxx)
    simple_format(xxx.description)
  end
end

步骤二:

app/views/xxxs/index.html.erb和app/views/account/xxxs/index.html.erb里关于xxx.description的部分换成:
<td><%= render_xxx_description(xxx) %></td>

Comments

comments powered by Disqus