vhochstein fork: helper methods namespace collide

106 views
Skip to first unread message

Nick Rogers

unread,
Jun 17, 2011, 10:00:11 AM6/17/11
to actives...@googlegroups.com
In active_scaffold vhochstein fork under rails 3.0.5, if you create a form or column helper method override for two different scaffold controllers having an attribute with the same name, they overwrite one another.

For example, using volker's demo app.

# is NEVER called for players scaffold
module PlayersHelper
  def name_column(record)
    "a Player: #{record.name}"
  end
end

# this is called by teams AND players scaffold
module TeamsHelper
  def name_column(record)
    "a Team: #{record.name}"
  end
end

Players
Name Date of birth Injured Salary Team Created at Updated at
a Team: nick - 0.000 test Tue, 14 Jun 2011 14:57:20 +0000 Tue, 14 Jun 2011 14:57:52 +0000 Edit Delete Show

I'm having similar problems with my rails 2.3 app that I'm trying to convert to rails 3. Is this a rails3 problem, active_scaffold issue, or something I'm doing incorrectly? Thanks.

vhochstein

unread,
Jun 18, 2011, 5:36:19 AM6/18/11
to ActiveScaffold : Ruby on Rails plugin
Hi,

rails 3 is including all helpers as a default.

Either, turn off that feature
or, define only one method name_column and do a case statement by
record class.

--
Volker

On 17 Jun., 16:00, Nick Rogers <ncrog...@gmail.com> wrote:
> In active_scaffold vhochstein fork under rails 3.0.5, if you create a form
> or column helper method override for two different scaffold controllers
> having an attribute with the same name, they overwrite one another.
>
> For example, using volker's demo app.
>
> # is NEVER called for players scaffold
> module PlayersHelper
>   def name_column(record)
>     "a Player: #{record.name}"
>   end
> end
>
> # this is called by teams AND players scaffold
> module TeamsHelper
>   def name_column(record)
>     "a Team: #{record.name}"
>   end
> end
>
> Players
> *Name* Date of birth Injured Salary Team Created at Updated at
> *a Team*: nick - 0.000 test Tue, 14 Jun 2011 14:57:20 +0000 Tue, 14 Jun 2011

Nick Rogers

unread,
Jun 18, 2011, 11:41:54 AM6/18/11
to actives...@googlegroups.com
That helped. Thanks.

For anyone else having this problem, apparently there isn't a well-documented way to turn this off. However, you can add the following to ApplicationController (or a subclass of).

# disable implicit helper(:all) in rails3
clear_helpers

Reference:


--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to actives...@googlegroups.com.
To unsubscribe from this group, send email to activescaffol...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.


Reply all
Reply to author
Forward
0 new messages