Vyacheslav Loginov
Vyacheslav Loginov

Reputation: 3216

How to write helper in Rails

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

Upvotes: 0

Views: 187

Answers (1)

David Sulc
David Sulc

Reputation: 25994

Since this code would deal with posts, you should put it in app/helpers/posts_helper.rb

Upvotes: 1

Related Questions