# Rails can't call method in partial

**URL:** <https://www.ruby-forum.com/t/rails-cant-call-method-in-partial/233675>\
**Category:** Rails\
**Created:** [January 2, 2015, 7:39pm UTC](https://www.ruby-forum.com/t/rails-cant-call-method-in-partial/233675 "2015-01-02T19:39:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [January 2, 2015, 7:39pm UTC](https://www.ruby-forum.com/t/rails-cant-call-method-in-partial/233675/1 "2015-01-02T19:39:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Alain\_Goldman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cdc98d/32.png) [@Alain\_Goldman](https://www.ruby-forum.com/u/Alain_Goldman)\
**Post date:** [January 3, 2015, 4:52pm UTC](https://www.ruby-forum.com/t/rails-cant-call-method-in-partial/233675/2 "2015-01-03T16:52:29Z")

</div>

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  
[http://apidock.com/rails/ActionController/Helpers/ClassMethods/helper\_method](http://apidock.com/rails/ActionController/Helpers/ClassMethods/helper_method)
