Sunday, October 21, 2012

Re: [Rails] Impossible to get data with ActiveResource

On 21 October 2012 11:45, chardy <thibaud.ch@gmail.com> wrote:
> Thanks for your help Colin!
>
> My logs :
>
>>> Started GET "/users/index" for 127.0.0.1 at Thu Oct 18 23:01:19 +0200
>>> 2012
>>>
>>> Processing by UsersController#index as HTML
>>>
>>> Rendered users/index.html.erb within layouts/application (0.6ms)
>>>
>>> Completed 500 Internal Server Error in 140ms
>>>
>>>
>>> ActionView::Template::Error (undefined method `each' for nil:NilClass):
>>>
>>> 1: <% @users.each do |user| %>
>>>
>>> 2: <h1><%= user.username %></h1>
>>>
>>> 3:
>>>
>>> 4: <% end %>
>>>
>>> app/views/users/index.html.erb:1:in
>>> `_app_views_users_index_html_erb___162613411_2191123680'
>
>
> I think the problem is the Error 500...? It's strange because if you try the
> link in the browser it's works...

The 500 error is not the problem, that is just the result of @users being nil.

I think you need to enable logging so that you can see what
activeresource is doing. I have not used activeresource but a quick
google found [1] which looks useful and has a section Logging
Requests. Hopefully you will then see what is going on.

Colin

[1] http://ofps.oreilly.com/titles/9780596521424/activeresource_id59243.html

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate