dimanche 12 juin 2016

undefined local variable or method `env' for main:Object

this is a ruby on rails project for recipe finder

i am getting this error
NameError in RecipesController#index
undefined local variable or method `env' for main:Object

recipe.rb

class Recipe < ActiveRecord::Base
  include HTTParty

  key_value = ENV['FOOD2FORK_KEY']
  hostport = ENV['FOOD2FORK_SERVER_AND_PORT'] || 'www.food2fork.com'
  base_uri "http://#{hostport}/api/search"
  default_params key: key_value
  format :json

  def self.for term
    get("", query: { query: term})['recipes']
  end
end

recipes_controller.rb

class RecipesController < ApplicationController
  def index
    @search_term = params[:search] ||  'chocolate'
    @recipes = Recipe.for(@search_term)
  end
end

recipes_controller.rb

class RecipesController < ApplicationController
  def index
    @search_term = params[:search] ||  'chocolate'
    @recipes = Recipe.for(@search_term)
  end
end

i am using rails 4.2.6 and ruby 2.2.0

Aucun commentaire:

Enregistrer un commentaire