Indentifier needs to be constant error when calling Struct.n

In my current rails application, I now have the following issue:

script/console
Loading development environment.

bob = Struct.new(:anysymbol)
NameError: identifier anysymbol needs to be constant
from (irb):1:in `new’
from (irb):1

exit

This occurs regardless of what symbols are passed to Struct.new call.

Consequently, nothing that uses Struct will work anymore. I
discovered this when attempting to use Fastercsv, which fails when
required.

I’m completely mystified by this error and have little idea how to go
about tracking down what is causing it, short of rebuilding my
application one step at a time. It’s fairly big to be doing with at
this point.

What could cause such a problem?

I’ve made no monkeypatches to Struct. I can’t find any code messing
with Struct among the plugins I’ve installed.

Help.

Michael J.

whew. I managed to discover this relatively quickly once I quelled my
panic.

It was caused by an extension called acts_as_wizard, which
monkeypatches Symbol thusly:

class Symbol
…some other monkeycrap^H^H^H^Hpatching
def to_str
id2name
end
end

I’m not entirely sure how this ends up breaking Struct.new, but it
does. It’s a lame patch anyway, he should just use id2name or “#
{mysymbol}” instead of making such a patch. Coercions and other such
things that are likely to be pervasively used outside of the code you
are writing are bad bad targets for monkeypatching.

Since the time I installed acts_as_wizard, I have stopped using it
and written my own wizard management code, so luckily I can easily
just pitch this plugin.

Michael J.

Hey thanks for this info, I’ve been having the same problems with
net/sftp and net/imap and could not figure out the reason, turned out to
be the act_as_wizard plugin!

Michael J. wrote:

whew. I managed to discover this relatively quickly once I quelled my
panic.

It was caused by an extension called acts_as_wizard, which
monkeypatches Symbol thusly:

class Symbol
…some other monkeycrap^H^H^H^Hpatching
def to_str
id2name
end
end

I’m not entirely sure how this ends up breaking Struct.new, but it
does. It’s a lame patch anyway, he should just use id2name or “#
{mysymbol}” instead of making such a patch. Coercions and other such
things that are likely to be pervasively used outside of the code you
are writing are bad bad targets for monkeypatching.

Since the time I installed acts_as_wizard, I have stopped using it
and written my own wizard management code, so luckily I can easily
just pitch this plugin.

Michael J.