Request.params causing errors

Hello,

I have a rhtml file that goes through the request.params. One of my
test
generates that file, but rspec pops an error saying :

undefined method ‘params’ for …

I’m not sure what to do with this, since request.params actually works
with
rails.

Any idea?

Thank you

Olivier D.

Please post spec, code and error message.

Sorry about that. Here goes…

Spec:

describe “/search/index” do
it “should have option to login” do
render “/search/index”
response.should have_text(/Login/)
end
end

Code for index.rhtml

*



<%= render_component :controller =>
“components”,
:action => “footer”, :params => { :lang => @language } %>

*

Code for footer.rhtml

*<% listOfParameters = “” %>
<% request.params.each do |param| %>
<% if param[0].to_s != “lang” %>
<% listOfParameters = listOfParameters + “&” + param[0].to_s +
“=” +
param[1].to_s %>
<% end %>
<% end %>

…*

Now the error message:

*ActionView::TemplateError in ‘/search/index should have option to
login’
undefined method ‘params’ for #ActionController::TestRequest:0x46a044c
On line #7 of app/views/components/footer.rhtml

**6: <% listOfParameters = “” %>
7: <% request.params.each do |param| %>
8: <% if param[0].to_s != “lang” %>
9: <% listOfParameters = listOfParameters + “&” + param[0].to_s
+
“=” + param[1].to_s %>
10: <% end %>
11: <% end %>

*Thanks again

Olivier D.

On Fri, Apr 11, 2008 at 3:26 PM, David C. [email protected]

It unfortunately access the wrong parameters. Instead of accessing the
parameters from my url request, it access the parameters from my
render_component.

For example, my request is
*
http://localhost:4000/search/results?author=&keyword=&page=1&publisher=&title=agile
*

In that results view, I render this component
<%= render_component :controller => “components”, :action => “footer”,
:params => { :lang => @language } %>

So in the footer component, when I execute
<% request.params.each do |param| %>
it goes through the params from *
http://localhost:4000/search/results?author=&keyword=&page=1&publisher=&title=agile

*But if I execute
*<% params.each do |param| %>
*it goes through the params from *<%= render_component :controller =>
“components”, :action => “footer”, :params => { :lang => @language } %>

*My test passes when I use only params.each but not when I use *
request.params.each

*Thanks again

Olivier D.

On Fri, Apr 11, 2008 at 4:05 PM, David C. [email protected]

On Apr 11, 2008, at 3:53 PM, Olivier D. wrote:

6: <% listOfParameters = “” %>
7: <% request.params.each do |param| %>

Try just params (not request.params) - does that work?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs