Rails can't call method in partial

33 views
Skip to first unread message

Alain Goldman

unread,
Jan 2, 2015, 11:04:16 AM1/2/15
to rubyonra...@googlegroups.com

When I to call a method in a partial I get a 'undefined local method for class' error.

in my view, home.haml

    = render "layouts/side"

in my partial /layouts/_side.haml

    %div
      - test_method?
        Is true.

In the controller that serves home.haml I put

    def test_method?
      return true
    end

I even tried putting the method in the application helper file, no cigar. Any ideas?

dasibre

unread,
Jan 3, 2015, 10:51:13 AM1/3/15
to rubyonra...@googlegroups.com
You need to use helper_method :test_method? in your Application helper file. I believe this will give you access to the method inside the view
Reply all
Reply to author
Forward
0 new messages