alex77000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Aug-20 16:13 UTC
You have a nil object when you didn''t expect it ?
Hello, I''m trying a simple AJAX test link with the following code inside my view : <%= link_to_remote( "[Total]", { :action => "total", :update => "letotal" } ) %> <div id="letotal"> </div> In my controller I put : def total @res = Person.find(:all) render_text "Il y a #{@res.size} personnes dans le carnet" end When I test it, I get the following error message : You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] Thank you for your help --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Aug-20 16:17 UTC
Re: You have a nil object when you didn''t expect it ?
On 20 Aug 2008, at 17:13, alex77000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > Hello, > > I''m trying a simple AJAX test link with the following code inside my > view : > > <%= link_to_remote( "[Total]", { :action => "total", :update => > "letotal" } ) %> > > <div id="letotal"> > </div> > > In my controller I put : > > def total > @res = Person.find(:all) > render_text "Il y a #{@res.size} personnes dans le carnet" > end >Unrelated to this but it''s way way more efficient to say @number_of_people = Person.count rather that use Person.find(:all).size> When I test it, I get the following error message : > > You have a nil object when you didn''t expect it! > You might have expected an instance of ActiveRecord::Base. > The error occurred while evaluating nil.[] >What''s the line throwing that exception ? Fred> Thank you for your help > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alexandre Brillant
2008-Aug-20 16:19 UTC
Re: You have a nil object when you didn''t expect it ?
*on <%= link_to_remote( "[Total]", { :action => "total", :update =>> "letotal" } ) %>*If I put it in comment there''s no error. On Wed, Aug 20, 2008 at 6:17 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 20 Aug 2008, at 17:13, alex77000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > Hello, > > > > I''m trying a simple AJAX test link with the following code inside my > > view : > > > > <%= link_to_remote( "[Total]", { :action => "total", :update => > > "letotal" } ) %> > > > > <div id="letotal"> > > </div> > > > > In my controller I put : > > > > def total > > @res = Person.find(:all) > > render_text "Il y a #{@res.size} personnes dans le carnet" > > end > > > > Unrelated to this but it''s way way more efficient to say > @number_of_people = Person.count rather that use Person.find(:all).size > > When I test it, I get the following error message : > > > > You have a nil object when you didn''t expect it! > > You might have expected an instance of ActiveRecord::Base. > > The error occurred while evaluating nil.[] > > > What''s the line throwing that exception ? > > Fred > > Thank you for your help > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Aug-20 16:20 UTC
Re: You have a nil object when you didn''t expect it ?
On 20 Aug 2008, at 17:19, Alexandre Brillant wrote:> on <%= link_to_remote( "[Total]", { :action => "total", :update => > > "letotal" } ) %> > > If I put it in comment there''s no error. >D''oh. That should be link_to_remote "[Total"], :url => {:action => ''total''}, :update => ''letotal'' Fred> > On Wed, Aug 20, 2008 at 6:17 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > wrote: > > > On 20 Aug 2008, at 17:13, alex77000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > Hello, > > > > I''m trying a simple AJAX test link with the following code inside my > > view : > > > > <%= link_to_remote( "[Total]", { :action => "total", :update => > > "letotal" } ) %> > > > > <div id="letotal"> > > </div> > > > > In my controller I put : > > > > def total > > @res = Person.find(:all) > > render_text "Il y a #{@res.size} personnes dans le carnet" > > end > > > > Unrelated to this but it''s way way more efficient to say > @number_of_people = Person.count rather that use > Person.find(:all).size > > When I test it, I get the following error message : > > > > You have a nil object when you didn''t expect it! > > You might have expected an instance of ActiveRecord::Base. > > The error occurred while evaluating nil.[] > > > What''s the line throwing that exception ? > > Fred > > Thank you for your help > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alexandre Brillant
2008-Aug-20 16:21 UTC
Re: You have a nil object when you didn''t expect it ?
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/url_rewriter.rb:102:in `rewrite_url'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/url_rewriter.rb:88:in `rewrite'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:621:in `url_for'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/url_helper.rb:76:in `send'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/url_helper.rb:76:in `url_for'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/prototype_helper.rb:461:in `remote_function'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/prototype_helper.rb:255:in `link_to_remote'' app/views/carnet/voir.html.erb:15:in `_run_erb_47app47views47carnet47voir46html46erb'' On Wed, Aug 20, 2008 at 6:17 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 20 Aug 2008, at 17:13, alex77000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > Hello, > > > > I''m trying a simple AJAX test link with the following code inside my > > view : > > > > <%= link_to_remote( "[Total]", { :action => "total", :update => > > "letotal" } ) %> > > > > <div id="letotal"> > > </div> > > > > In my controller I put : > > > > def total > > @res = Person.find(:all) > > render_text "Il y a #{@res.size} personnes dans le carnet" > > end > > > > Unrelated to this but it''s way way more efficient to say > @number_of_people = Person.count rather that use Person.find(:all).size > > When I test it, I get the following error message : > > > > You have a nil object when you didn''t expect it! > > You might have expected an instance of ActiveRecord::Base. > > The error occurred while evaluating nil.[] > > > What''s the line throwing that exception ? > > Fred > > Thank you for your help > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alexandre Brillant
2008-Aug-21 06:51 UTC
Re: You have a nil object when you didn''t expect it ?
Thank you Fred On Wed, Aug 20, 2008 at 6:20 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 20 Aug 2008, at 17:19, Alexandre Brillant wrote: > > > on <%= link_to_remote( "[Total]", { :action => "total", :update => > > > "letotal" } ) %> > > > > If I put it in comment there''s no error. > > > D''oh. That should be link_to_remote "[Total"], :url => {:action => > ''total''}, :update => ''letotal'' > > Fred > > > > > On Wed, Aug 20, 2008 at 6:17 PM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > wrote: > > > > > > On 20 Aug 2008, at 17:13, alex77000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > > > > Hello, > > > > > > I''m trying a simple AJAX test link with the following code inside my > > > view : > > > > > > <%= link_to_remote( "[Total]", { :action => "total", :update => > > > "letotal" } ) %> > > > > > > <div id="letotal"> > > > </div> > > > > > > In my controller I put : > > > > > > def total > > > @res = Person.find(:all) > > > render_text "Il y a #{@res.size} personnes dans le carnet" > > > end > > > > > > > Unrelated to this but it''s way way more efficient to say > > @number_of_people = Person.count rather that use > > Person.find(:all).size > > > When I test it, I get the following error message : > > > > > > You have a nil object when you didn''t expect it! > > > You might have expected an instance of ActiveRecord::Base. > > > The error occurred while evaluating nil.[] > > > > > What''s the line throwing that exception ? > > > > Fred > > > Thank you for your help > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---