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
Post a Comment