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
On Sep 4, 4:17 pm, Lee Fyock <lee.fy...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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> Thanks, > Lee
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 Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 4, 4:17 pm, LeeFyock<lee.fy...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > > > > Thanks, > > Lee