Retrieving value from @params

I’m recieving the error “You have a nil object when you didn’t expect
it!
The error occured while evaluating nil.each_hash”, when trying to access
a value
from params. I’m trying to get the value with

@c = @params[‘CourseSection’][‘section_name’]

@params contains the following data

{“commit”=>“Submit”, “CourseSection”=>{“term”=>“fall”,
“course_subject”=>“cs”, “section_number”=>“101”,
“course_number”=>“153”}}

Any idea what I could be doing wrong.

-Shaun

use

@c = @params[‘CourseSection’][‘section_number’]

instead

christer wrote:

use

@c = @params[‘CourseSection’][‘section_number’]

instead

Sorry, misstyped it the first time arouund. I am using
@c = @params[‘CourseSection’][‘section_number’] and recieving the error
mentioned above.

On 21 Nov 2005, at 21:39, shaun wrote:

@c = @params[‘CourseSection’][‘section_name’]

{“commit”=>“Submit”, “CourseSection”=>{“term”=>“fall”,
“course_subject”=>“cs”, “section_number”=>“101”,
“course_number”=>“153”}}

Any idea what I could be doing wrong.

@params[‘CourseSection’][‘section_name’] is nil. You should set this,
perhaps by having a form field in the previous view: <%= text_field
“CourseSection”, “section_name” %>

Yours,
Craig

Craig W. | t: +44 (0)131 516 8595 | e: [email protected]
Xeriom.NET | f: +44 (0)709 287 1902 | w: http://xeriom.net

craig wrote:

On 21 Nov 2005, at 21:39, shaun wrote:

@c = @params[‘CourseSection’][‘section_name’]

{“commit”=>“Submit”, “CourseSection”=>{“term”=>“fall”,
“course_subject”=>“cs”, “section_number”=>“101”,
“course_number”=>“153”}}

Any idea what I could be doing wrong.

@params[‘CourseSection’][‘section_name’] is nil. You should set this,
perhaps by having a form field in the previous view: <%= text_field
“CourseSection”, “section_name” %>

Yours,
Craig

Craig W. | t: +44 (0)131 516 8595 | e: [email protected]
Xeriom.NET | f: +44 (0)709 287 1902 | w: http://xeriom.net

I don’t understand why @params[‘CourseSection’][‘section_number’] would
be nil.
CourseSection is a hash in a hash, so by asking for
@params[‘CourseSection’][‘section_name’] should I not recieve the value
for section_number, being “153” in this case.

On 21 Nov 2005, at 22:01, shaun wrote:

I don’t understand why @params[‘CourseSection’][‘section_number’]
would
be nil.
CourseSection is a hash in a hash, so by asking for
@params[‘CourseSection’][‘section_name’] should I not recieve the
value
for section_number, being “153” in this case.

Okay, let’s clarify: do you want the section_name or the section_number?

Yours,
Craig

Craig W. | t: +44 (0)131 516 8595 | e: [email protected]
Xeriom.NET | f: +44 (0)709 287 1902 | w: http://xeriom.net

craig wrote:

On 21 Nov 2005, at 22:01, shaun wrote:

I don’t understand why @params[‘CourseSection’][‘section_number’]
would
be nil.
CourseSection is a hash in a hash, so by asking for
@params[‘CourseSection’][‘section_name’] should I not recieve the
value
for section_number, being “153” in this case.

Okay, let’s clarify: do you want the section_name or the section_number?

Yours,
Craig

Craig W. | t: +44 (0)131 516 8595 | e: [email protected]
Xeriom.NET | f: +44 (0)709 287 1902 | w: http://xeriom.net

section_number is what I’m trying to get. Despite the fact that I keep
typing it, section_name does not exist.

Sean,

You must have something else wrong in your real code, because the
code you’ve provided works just fine:

irb(main):001:0> x = {“commit”=>“Submit”, “CourseSection”=>
{“term”=>“fall”,
irb(main):002:2* “course_subject”=>“cs”, “section_number”=>“101”,
irb(main):003:2* “course_number”=>“153”}}
=> {“commit”=>“Submit”, “CourseSection”=>{“course_subject”=>“cs”,
“term”=>“fall”, “section_number”=>“101”, “course_number”=>“153”}}
irb(main):004:0> x[“CourseSection”][“section_number”]
=> “101”

Cheers,

Pete Y.

shaun [email protected] [email protected] wrote:

craig wrote:

On 21 Nov 2005, at 21:39, shaun wrote:

@c = @params[‘CourseSection’][‘section_name’]

{“commit”=>“Submit”, “CourseSection”=>{“term”=>“fall”,
“course_subject”=>“cs”, “section_number”=>“101”,
“course_number”=>“153”}}

Any idea what I could be doing wrong.

@params[‘CourseSection’][‘section_name’] is nil. You should set this,
perhaps by having a form field in the previous view: <%= text_field
“CourseSection”, “section_name” %>

Yours,
Craig

Craig W. | t: +44 (0)131 516 8595 | e: [email protected]
Xeriom.NET | f: +44 (0)709 287 1902 | w: http://xeriom.net

I don’t understand why @params[‘CourseSection’][‘section_number’] would
be nil.
CourseSection is a hash in a hash, so by asking for
@params[‘CourseSection’][‘section_name’] should I not recieve the value
for section_number, being “153” in this case.

crap I can’t type today. section_name is actually section_number.

I don’t understand why @params[‘CourseSection’][‘section_number’] would
be nil. CourseSection is a hash in a hash, so by asking for
@params[‘CourseSection’][‘section_number’] should I not recieve the
value
for section_number, being “153” in this case.