From: Kendall Gifford Date: 2013-05-17T22:13:31+09:00 Subject: Re: Error in Migration --089e01493cba51a71604dce9a7da Content-Type: text/plain; charset=UTF-8 On Fri, May 17, 2013 at 12:37 AM, Amarnath Krishnan wrote: > I am a RoR newbie. I am getting this error when trying to migrate my 2.x > project to 3.x project. > actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:109:in > `normalize_path': undefined method `to_sym' for nil:NilClass > (NoMethodError) > > In that line i can see the following code > options[$1.to_sym]||=/.+/? > > why $1.to_sym ends with NilClass error > You're getting NoMethodError because $1 in $1.to_sym is nil and nil doesn't have a #to_sym method. $1 gets set whenever you #match a string against a regular expression that has at least one capture group. By the time your line of code gets executed, you clearly haven't done so. Also, the question mark at the end of the line as you've show it: options[$1.to_sym]||=/.+/? Is invalid (type it into an IRB session after initializing a local variable "options" to an empty hash and you'll see that the parser things you're starting a ternary: "condition ? when-true : when-false" expression and doesn't consider the statement complete. Did you mean to have the "?" after the "+" _inside_ the regular expression? So, without more info on what you're trying to get this line of code to do (what you expect $1 to be at this point, etc.) that's all the help I can give. -- Kendall Gifford zettabyte@gmail.com --089e01493cba51a71604dce9a7da Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Fri, May 17, 2013 at 12:37 AM, Amarnath Krishnan <l= ists@ruby-forum.com> wrote:
I am a RoR newbie. I am g= etting this error when trying to migrate my 2.x
project to 3.x project.
actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:109:in
`normalize_path': undefined method `to_sym' for nil:NilClass
(NoMethodError)

In that line i can see the following code
options[$1.to_sym]||=3D/.+/?

why $1.to_sym ends with NilClass error

You're getting= NoMethodError because $1 in $1.to_sym is nil and nil doesn't have a #t= o_sym method.

$1 gets set whenever you #match a string ag= ainst a regular expression that has at least one capture group. By the time= your line of code gets executed, you clearly haven't done so.

Also, the question mark at the end of the line as you've= show it:

options[$1.to_sym]||=3D/.+/?

Is invalid = (type it into an IRB session after initializing a local variable "opti= ons" to an empty hash and you'll see that the parser things you= 9;re starting a ternary: "condition ? when-true : when-false" exp= ression and doesn't consider the statement complete. Did you mean to ha= ve the "?" after the "+" _inside_ the regular expressio= n?

So, without more info on what you're trying to get this = line of code to do (what you expect $1 to be at this point, etc.) that'= s all the help I can give.

--
Kendall Gifford
zettabyte@gmail.com
--089e01493cba51a71604dce9a7da--