# NameError / unitialized constant

**URL:** <https://www.ruby-forum.com/t/nameerror-unitialized-constant/145341>\
**Category:** Rails\
**Created:** [August 8, 2008, 7:28am UTC](https://www.ruby-forum.com/t/nameerror-unitialized-constant/145341 "2008-08-08T07:28:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [August 8, 2008, 7:28am UTC](https://www.ruby-forum.com/t/nameerror-unitialized-constant/145341/1 "2008-08-08T07:28:12Z")

</div>

Ok I’m trying to use the Yelp gem which I’ve installed. Following the  
documention I do the following in my CONTROLLER:

in ‘location\_controller.rb’

def search

client = Yelp::Client.new  
request = Yelp::Review::Request::Location.new(  
:address =\> ‘650  
Mission St’,  
:city =\> ‘San  
Francisco’,  
:state =\> ‘CA’,  
:radius =\> 2,  
:term =\> ‘cream  
puffs’,  
:yws\_id =\> ‘xxxx’)  
response = client.search(request)

@yelp\_results = response  
end

Well the first line causes the following error:

NameError (uninitialized constant LocationsController::Yelp):  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/dependencies.rb:492:in  
`const_missing' /app/controllers/locations_controller.rb:18:in`search’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/base.rb:1162:in  
`send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in`perform\_action\_withou  
t\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/filters.rb:580:in  
`call_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:573:in`perform\_action\_with  
out\_benchmark’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_controller/benchmarking.rb:68:in  
`perform\_action\_  
without\_rescue’

Am i not supposed to instantiate this in the controller?

Thanks

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [August 8, 2008, 7:34am UTC](https://www.ruby-forum.com/t/nameerror-unitialized-constant/145341/2 "2008-08-08T07:34:25Z")

</div>

1 ) have you restarted your server?  
2) Did you do require ‘yelp’ in config/environment.rb?  
3) ???

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [August 8, 2008, 7:38am UTC](https://www.ruby-forum.com/t/nameerror-unitialized-constant/145341/3 "2008-08-08T07:38:55Z")

</div>

adding “require ‘yelp’” to config/environment.rb did the trick.

thanks!

Ryan B. wrote:

> 1 ) have you restarted your server?  
> 2) Did you do require ‘yelp’ in config/environment.rb?  
> 3) ???
