cat
cat

Reputation: 749

Is it possible to have 'link_to' within application_helper.rb?

I'm trying to make a link in common. So I tried to make one in application_helper.rb.

But it seems not possible. How do I usually do this when I want to make link which will be used in common.

application_helper.rb

module ApplicationHelper

  def platform_search(genre_id)
      <%= link_to "<span class='btn btn-danger'>#{community.genre.name}</span>".html_safe, communities_path(:search => '' ,:genre => community.genre_id )%>
  end

end

Upvotes: 0

Views: 111

Answers (1)

Zabba
Zabba

Reputation: 65497

You should be able to use link_to in helpers. You are getting an error due to <%=.

The <%= %> is syntax for ERB (think views), not Ruby. Remove those delimiters.

Upvotes: 4

Related Questions