Helper methods with same name overwriting each other

4 views
Skip to first unread message

Jose Fernandez

unread,
Mar 20, 2008, 3:42:18 PM3/20/08
to ActiveScaffold : Ruby on Rails plugin
I've got 2 helper files for 2 different models and each has the same
method name:

def uploaded_data_column(record)
.....
end

The problem is that only one of the helper methods gets triggered for
both models and I have to add this at the top of the methods for them
to fire off correctly:

if record.class.name == 'Image' ..... or if record.class.name ==
'Audio'

Is this a known bug?

Adam Spiers

unread,
Mar 24, 2008, 3:07:47 PM3/24/08
to ActiveScaffold : Ruby on Rails plugin
On Mar 20, 7:42 pm, Jose Fernandez <fernandez.joser...@gmail.com>
wrote:
> I've got 2helperfiles for 2 different models and each has the same
> method name:
>
> def uploaded_data_column(record)
> .....
> end
>
> The problem is that only one of thehelpermethods gets triggered for
> both models

I see this too :-( In my case I don't even have a direct association
between
the two models, although there is an intermediary table which
belongs_to both.

> and I have to add this at the top of the methods for them
> to fire off correctly:
>
> if record.class.name == 'Image' ..... or if record.class.name ==
> 'Audio'

You mean you merge both helper methods into one, then do if ...
else ...
on the unified one? Or is there a way of indicating in one helper
that
the caller should pretend it doesn't exist? Please could you paste
full
code if you have a workaround, thanks!
Reply all
Reply to author
Forward
0 new messages