title: Class from installed gem not recognized by model
body: <p>Within model <code>Venue</code> I am storing location data as a <a href="https://github.com/alexreisner/geocoder" rel="nofollow noreferrer">Geocoder</a> object, which is acquired via <code>Geocoder.search</code> from a text input when a <code>Venue</code> is created. The location data object, which is of class <code>Geocoder::Result::Google</code>, is serialized and saved in a <code>text</code> column in the <code>venues</code> table.</p>
  
  <pre><code>class Venue &lt; ActiveRecord::Base
  
      serialize :location
      before_validation :get_location
  
      def get_location
          return false unless venue_text
          self.location = Geocoder.search(venue_text).first
      end
  
  end
  </code></pre>
  
  <p>When I first create an object in Rails console</p>
  
  <pre><code>2.3.0 :001 &gt; Venue.create(venue_text: 'Madison Square Garden, New York City, New York')
     (0.1ms)  begin transaction
    SQL (0.8ms)  INSERT INTO "venues" ("venue_text", "location", "time_zone", "name", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?)  [["venue_text", "Madison Square Garden, New York City, New York"], ["location", "--- !ruby/object:Geocoder::Result::Google\ndata:\n  address_components:\n  - long_name: '4'\n    short_name: '4'\n    types:\n    - street_number\n  - long_name: Pennsylvania Plaza\n    short_name: Pennsylvania Plaza\n    types:\n    - route\n  - long_name: Manhattan\n    short_name: Manhattan\n    types:\n    - political\n    - sublocality\n    - sublocality_level_1\n  - long_name: New York\n    short_name: New York\n    types:\n    - locality\n    - political\n  - long_name: New York County\n    short_name: New York County\n    types:\n    - administrative_area_level_2\n    - political\n  - long_name: New York\n    short_name: NY\n    types:\n    - administrative_area_level_1\n    - political\n  - long_name: United States\n    short_name: US\n    types:\n    - country\n    - political\n  - long_name: '10001'\n    short_name: '10001'\n    types:\n    - postal_code\n  formatted_address: 4 Pennsylvania Plaza, New York, NY 10001, USA\n  geometry:\n    location:\n      lat: 40.7505045\n      lng: -73.9934387\n    location_type: APPROXIMATE\n    viewport:\n      northeast:\n        lat: 40.7518534802915\n        lng: -73.99208971970849\n      southwest:\n        lat: 40.7491555197085\n        lng: -73.9947876802915\n  place_id: ChIJhRwB-yFawokR5Phil-QQ3zM\n  types:\n  - establishment\n  - point_of_interest\n  - stadium\ncache_hit: \n"], ["time_zone", "America/New_York"], ["name", "Madison Square Garden"], ["created_at", "2017-03-26 02:46:47.808170"], ["updated_at", "2017-03-26 02:46:47.808170"]]
     (12.4ms)  commit transaction
   =&gt; #&lt;Venue id: 1, name: "Madison Square Garden", team_id: nil, venue_text: "Madison Square Garden, New York City, New York", location: #&lt;Geocoder::Result::Google:0x00000003994dc0 @data={"address_components"=&gt;[{"long_name"=&gt;"4", "short_name"=&gt;"4", "types"=&gt;["street_number"]}, {"long_name"=&gt;"Pennsylvania Plaza", "short_name"=&gt;"Pennsylvania Plaza", "types"=&gt;["route"]}, {"long_name"=&gt;"Manhattan", "short_name"=&gt;"Manhattan", "types"=&gt;["political", "sublocality", "sublocality_level_1"]}, {"long_name"=&gt;"New York", "short_name"=&gt;"New York", "types"=&gt;["locality", "political"]}, {"long_name"=&gt;"New York County", "short_name"=&gt;"New York County", "types"=&gt;["administrative_area_level_2", "political"]}, {"long_name"=&gt;"New York", "short_name"=&gt;"NY", "types"=&gt;["administrative_area_level_1", "political"]}, {"long_name"=&gt;"United States", "short_name"=&gt;"US", "types"=&gt;["country", "political"]}, {"long_name"=&gt;"10001", "short_name"=&gt;"10001", "types"=&gt;["postal_code"]}], "formatted_address"=&gt;"4 Pennsylvania Plaza, New York, NY 10001, USA", "geometry"=&gt;{"location"=&gt;{"lat"=&gt;40.7505045, "lng"=&gt;-73.9934387}, "location_type"=&gt;"APPROXIMATE", "viewport"=&gt;{"northeast"=&gt;{"lat"=&gt;40.7518534802915, "lng"=&gt;-73.99208971970849}, "southwest"=&gt;{"lat"=&gt;40.7491555197085, "lng"=&gt;-73.9947876802915}}}, "place_id"=&gt;"ChIJhRwB-yFawokR5Phil-QQ3zM", "types"=&gt;["establishment", "point_of_interest", "stadium"]}, @cache_hit=nil&gt;, time_zone: "America/New_York", created_at: "2017-03-26 02:46:47", updated_at: "2017-03-26 02:46:47"&gt;
  </code></pre>
  
  <p>I can immediately get the location object</p>
  
  <pre><code>2.3.0 :002 &gt; Venue.first.location
    Venue Load (0.3ms)  SELECT  "venues".* FROM "venues"  ORDER BY "venues"."id" ASC LIMIT 1
   =&gt; #&lt;Geocoder::Result::Google:0x0000000b71bed8 @data={"address_components"=&gt;[{"long_name"=&gt;"4", "short_name"=&gt;"4", "types"=&gt;["street_number"]}, {"long_name"=&gt;"Pennsylvania Plaza", "short_name"=&gt;"Pennsylvania Plaza", "types"=&gt;["route"]}, {"long_name"=&gt;"Manhattan", "short_name"=&gt;"Manhattan", "types"=&gt;["political", "sublocality", "sublocality_level_1"]}, {"long_name"=&gt;"New York", "short_name"=&gt;"New York", "types"=&gt;["locality", "political"]}, {"long_name"=&gt;"New York County", "short_name"=&gt;"New York County", "types"=&gt;["administrative_area_level_2", "political"]}, {"long_name"=&gt;"New York", "short_name"=&gt;"NY", "types"=&gt;["administrative_area_level_1", "political"]}, {"long_name"=&gt;"United States", "short_name"=&gt;"US", "types"=&gt;["country", "political"]}, {"long_name"=&gt;"10001", "short_name"=&gt;"10001", "types"=&gt;["postal_code"]}], "formatted_address"=&gt;"4 Pennsylvania Plaza, New York, NY 10001, USA", "geometry"=&gt;{"location"=&gt;{"lat"=&gt;40.7505045, "lng"=&gt;-73.9934387}, "location_type"=&gt;"APPROXIMATE", "viewport"=&gt;{"northeast"=&gt;{"lat"=&gt;40.7518534802915, "lng"=&gt;-73.99208971970849}, "southwest"=&gt;{"lat"=&gt;40.7491555197085, "lng"=&gt;-73.9947876802915}}}, "place_id"=&gt;"ChIJhRwB-yFawokR5Phil-QQ3zM", "types"=&gt;["establishment", "point_of_interest", "stadium"]}, @cache_hit=nil&gt;
  </code></pre>
  
  <p>But if I exit from Rails console and do the same thing, the class is undefined.</p>
  
  <pre><code>2.3.0 :001 &gt; Venue.first.location
    Venue Load (0.2ms)  SELECT  "venues".* FROM "venues"  ORDER BY "venues"."id" ASC LIMIT 1
  ArgumentError: undefined class/module Geocoder::Result::Google
  </code></pre>
  
  <p>I thought that since the <code>geocoder</code> gem is installed on my application, the application should be able to recognize and define the classes and methods that come with the gem. Indeed, I was able to use <code>Geocoder.search</code> with no problems in my <code>get_location</code> method. What am I missing here?</p>