# Model attributes calling helper function?!

**URL:** <https://www.ruby-forum.com/t/model-attributes-calling-helper-function/174957>\
**Category:** Rails\
**Created:** [September 4, 2009, 5:19pm UTC](https://www.ruby-forum.com/t/model-attributes-calling-helper-function/174957 "2009-09-04T17:19:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [September 4, 2009, 5:19pm UTC](https://www.ruby-forum.com/t/model-attributes-calling-helper-function/174957/1 "2009-09-04T17:19:00Z")

</div>

I have a totally wacked problem going on.

I have a model attribute with the same name (“content”) as a helper  
function, and when I call “model.content”, it’s calling the “content”  
helper function instead of the model’s attribute.

This, of course, causes severe problems.

In our master branch, this is only reproducible on our production  
(Rails 2.1.1) machine, which sucks as far as trying to track it down.  
I’m working on my dev machine in a Rails 2.3.x branch, in which I can  
reproduce the problem with a test. Unfortunately, our code is large  
and complex, so I can’t easily tell if it’s something we’re doing, or  
an issue with Rails, or what.

Here’s the test result:  
test\_get\_new(MessagingControllerTest):  
NoMethodError: undefined method `content_tag' for "#<Letter: 0x5dc2ddc>":Letter app/helpers/our_ui_helper.rb:734:in`our\_content\_tag’  
app/helpers/our\_ui\_helper.rb:74:in `content' test/functional/messaging_controller_test.rb:122:in`test\_get\_new’

The failing line of the test is  
assert @reply.content.include?(@original.content), expectation

where @reply is a Letter object, which contains a “content” attribute.  
our\_ui\_helper.rb has a “content” method that’s used by templates.

Why in the world would “model.content” ever call a helper method?

Thanks,  
Lee

---

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [September 4, 2009, 5:34pm UTC](https://www.ruby-forum.com/t/model-attributes-calling-helper-function/174957/2 "2009-09-04T17:34:48Z")

</div>

On Sep 4, 4:17 pm, Lee F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a totally wacked problem going on.
> 
> I have a model attribute with the same name (“content”) as a helper  
> function, and when I call “model.content”, it’s calling the “content”  
> helper function instead of the model’s attribute.

is something including your helper module into the model ? (you could  
stick some logging in that module’s self.included) Does it only happen  
with your helper method or also the names of other helpers ?

Fred

---

<div class="post-metadata">

**Author:** ![lfeistel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lfeistel](https://www.ruby-forum.com/u/lfeistel)\
**Post date:** [September 9, 2009, 3:04pm UTC](https://www.ruby-forum.com/t/model-attributes-calling-helper-function/174957/3 "2009-09-09T15:04:27Z")

</div>

There was another model that was including ApplicationHelper for some  
godforsaken reason. Taking that out fixed the problem.

I’m still unclear why and how this was happening.

Lee

On Sep 4, 11:32 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
