[Nitro] Request#params

Robert Mela rob at robmela.com
Mon Oct 1 09:26:16 EDT 2007


You're right... but.... still....  I swear -- 'request[]' failed in 
nitro/part/admin/og/controller.rb in OgAdminController::save

I'll try a very simple test case to verify -- perhaps some code included 
via raw/model/webfile.rb is overriding it somehow...

The accessors do work as advertised in this case:

#!/usr/bin/env ruby
require 'nitro_and_og'
include Nitro


class Foo
  def index
     render_text "
       request() returns #{request.nil? ? 'nil' : request.class.name }
      <a href='/paramtest?a=b&c=d&foo=bar'>Parameters</a>
     "
  end
  def paramtest(*args)
    %{
        params=#{request.params}<br/>
        request[:foo] = #{request[:foo]}
     }
  end
end

app=Application.new
app.dispatcher.root = Foo
app.start


Jonathan Buch wrote:
> Hi,
>
>> OgAdminController#save attempts to access request data via the 'request'
>> method call:
>>
>> klass = name_to_class(*request*['object_class_name'].to_s)
>> obj.assign(*request*, :assign_relations => true, :force_boolean => true)
>
> yes, I believe that was always like that, as a shortcut to 
> request.params.
>
>> A couple problems
>>
>>   - Major misnomer: request returns a @context object
>
> That I don't know about.
>
>>   - @request does not have a [] method for accessing incoming request
>> variables ( nor should it...)
>
> Any reason why?
>
> * request.params['foo']
> * request['foo']
>
> I use the second form all the time.
>
>> I've worked around it for now by calling
>> @context.post_params['object_class_name'] .... which led up to the
>> question in my prev. email, since @context.params would be nicer...
>
> I'm not sure I follow you here.  The parameters come from the "Request"
> (requested by browser) and I'm not sure if 'context' better describes
> where the parameters come from.  IMO they belong to the current
> 'request cycle' and not to a 'generic context'.  But mind you, that is
> just generally, if Nitro returns a `Context` object when you call
> `request` then that's just kind of an alias....
>
>>>   31    def params
>>>   32        return method == :post ? @post_params : @get_params
>>>   33    end
>
> I'm not sure about the contents of those, but IIRC the plan (quite a 
> while
> back) was to do a little more:
>
> def params
>   return method == :post ? @get_params.merge(@post_params) : @get_params
> end
>
> (Where I assume the @get_params is an hash.)
>
> But that might now be obsolete when we have both .get/post_params 
> available.
>
> Carry on :P
>
> Jo
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rob.vcf
Type: text/x-vcard
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20071001/e8f25efa/attachment.vcf 


More information about the Nitro-general mailing list