def index cond = params[:letter] + "%" @clients = Client.find :all, :conditions => ["firstname like ?" , cond], :order => "firstname ASC" end This is my code and it gives me an error everytime saying this: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+ How can I fix this? Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> def index > cond = params[:letter] + "%" > @clients = Client.find :all, :conditions => ["firstname like ?" , > cond], :order => "firstname ASC" > end > > This is my code and it gives me an error everytime saying this: > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.+ > > How can I fix this?What is the value of params[:letter] ? If it''s nil you need to check for that... if params[:letter].nil? # or possibly .blank? # throw a hissy fit return end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:>> The error occurred while evaluating nil.+ >> >> How can I fix this? > > What is the value of params[:letter] ? If it''s nil you need to check > for > that... > > if params[:letter].nil? # or possibly .blank? > # throw a hissy fit > return > endOh i see! thats what my problem was, thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---