Skip to content

Can no longer use [] on cgi? #76

@rubyFeedback

Description

@rubyFeedback

Using this in a .cgi page:

require 'cgi'

cgi = CGI.new
value = cgi['field_name'] # => "123"
cgi['flowerpot'] # => ""
fields = cgi.keys # => [ "field_name" ]

cgi.has_key?('field_name') # => true
cgi.include?('field_name') # => true
cgi.include?('flowerpot') # => false

I am using the gem via gem install cgi by the way.

The error is:

misc.cgi:12:in '<main>': undefined method '[]' for an instance of CGI (NoMethodError)

cgi['name'] 

Is the [] method gone? Has something changed in the code?

I used to have a local copy of cgi and using that, I think [] and .params worked. But now
it does not work. Has the recent change in ruby caused this? Guess it is time to finally
switch to sinatra anyway - at the least param handling works there. But it is strange how
ruby has so many small issues lately. Can we go back to oldschool enginering again?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions