Question

in Rails (rails 4.0.0 rc2, ruby 1.9.3p429), in the Gemfile i've the following line:

gem 'google-api-client',  :require => 'google/api_client'

and then bundle install.

In a controller:

require 'google/api_client'

class PagesController < ApplicationController
   def home
      @client = Google::ApiClient.new
   end
end

If i go to 127.0.0.1:3000 i've the following error:

NameError in PagesController#home
uninitialized constant Google::ApiClient

Anyone can tell me how integrate the ruby google api in rails?

Thanks

Était-ce utile?

La solution

It is APIClient.new.

@client = Google::APIClient.new

You should also set the application name and version number or you get an ugly stdout when run your code. Like so :

@client = Google::APIClient.new(:application_name => "MyApplication",:application_version => "0.1")
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top