我的代码无法使用!它在终端中说了以下内容
未定义的局部变量或方法pikachu for main:Object (NameError)
代码:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RedirectToHome" stopProcessing="true">
<match url="^$" />
<conditions trackAllCaptures="true">
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{ToLower:{C:1}://{HTTP_HOST}/home/}" />
</rule>
<rule name="RedirectToWWW" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?://)(?!www[\.])" />
</conditions>
<action type="Redirect" url="{ToLower:{C:1}www[\.]{R:1}}" redirectType="Permanent" />
</rule>
<rule name="RewriteToParams" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="{ToLower:index.php?p=/{R:1}}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
答案 0 :(得分:2)
未定义的局部变量或方法pikachu for main:Object(NameError)
您的班级名称是Pokemon
,但您使用pikachu
导致该错误。您应该使用Pokemon
p = Pokemon.new("eletric", "pikachu", "100", "200")
同时删除p.initialize
这是不必要的,因为initialize
最终会调用new