JayX
JayX

Reputation: 1784

link_to not working in a helper module (rails)

So I was trying to call link_to in a helper module

here is the code

 module GroupsHelper

    include ActionView::Helpers::TextHelper
    include ActionView::Helpers::UrlHelper


   def self.link_to_publish
        link_to "test"  
    end


 end

It returns

 undefined local variable or method `link_to' for GroupsHelper:Module

Does anyone know why? Thx

Upvotes: 1

Views: 1188

Answers (1)

Aditya Sanghi
Aditya Sanghi

Reputation: 13433

Drop the "self.". It's not a class method.

Assumption: GroupsHelper is in rails app's app/helpers/groups_helper.rb

Upvotes: 2

Related Questions