ruby on rails - You have a nil object when you didn't expect it! You might have expected an instance of Array -


i writing below

def search     cuisine=settings.allcuisines   begin   @orgs = getsearch(params[:lat], params[:lon],params[:zip], params[:dist],   cuisine,params[:num_results])   respond_to |format|     format.html {render action: "index"}     format.json { render json: @orgs }   end     messg="success"     code="0"     results={:message=>messg,:code=>code}     resul=results.new(results)      resul.save   rescue exception => exc    messg=exc.message    code="1"    results={:message=>messg,:code=>code}    resul=results.new(results)      resul.save    respond_to |format|     format.html {render action: "index"}     format.json { render json: @orgs }    end  end 

i getting error:

you have nil object when didn't expect it! might have expected instance of array. error occurred while evaluating nil.each

why happening?

you calling @orgs.each in view , @orgs nil. can try nesting iterator in an:

- unless @orgs.nil?   - @orgs.each |o|     blah 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -