【问题标题】:How to write helper in Rails如何在 Rails 中编写助手
【发布时间】:2011-12-13 16:13:47
【问题描述】:

我需要检查用户收藏列表中的当前帖子

类似的东西(在视图中):

if in_favorites?
  #remove link
else
  #add link

我必须将助手代码放在application_controller.rbcurrent_controller#current_defcurrent_controller#custom_defapplication_helper.rb

【问题讨论】:

    标签: ruby-on-rails-3 helpers


    【解决方案1】:

    由于这段代码会处理帖子,你应该把它放在app/helpers/posts_helper.rb

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-08
      • 2018-03-08
      • 2020-05-05
      • 1970-01-01
      • 2010-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多