如何在 Rails 中编写助手
我需要检查用户收藏夹列表中的当前帖子是否
类似于(在视图中):
if in_favorites?
#remove link
else
#add link
Where I must place helper's code in application_controller.rb
, current_controller#current_def
, current_controller#custom_def
或在 application_helper.rb
中
I need to check is the current post in users favorites list
something like(in view):
if in_favorites?
#remove link
else
#add link
Where I must place helper's code in application_controller.rb
, current_controller#current_def
, current_controller#custom_def
or in application_helper.rb
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于此代码将处理帖子,因此您应该将其放入
app/helpers/posts_helper.rb
Since this code would deal with posts, you should put it in
app/helpers/posts_helper.rb