Google APi ruby โ€‹โ€‹client

I have a way to create a folder on google drive as soon as the create method is created. I want the folder to be created after saving the batch. Below is the code using Im. See the below redirect method page as soon as it is resolved. So the desktop query

 def create
    client = Signet::OAuth2::Client.new(
      :authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
      :token_credential_uri =>  'https://www.googleapis.com/oauth2/v3/token',
      :client_id => "XXXXXX-XXXXXX",
      :client_secret => "XXXXXX-XXX",
      :scope => 'https://www.googleapis.com/auth/drive',
      :redirect_uri => "http://localhost:3000/batches/"
      )
    @batch = Batch.new(params[:batch])

    respond_to do |format|
      if @batch.save

        if params[:code].present?
          client.code = request['code']
          client.fetch_access_token!
          x = Google::Apis::DriveV3::DriveService.new
          x.authorization = client
          files = x.list_files(options: { authorization: client })
          file_metadata = {
            name: 'Batches-new',
            mime_type: 'application/vnd.google-apps.folder',
          }
        file = x.create_file(file_metadata, fields: 'id')
            Rails.logger.debug "Folder Id: #{file.id}"
        else
          format.html {redirect_to client.authorization_uri.to_s}
        end

        format.html {redirect_to batches_path(trek_id: @batch.trek_id), notice: 'Batch was successfully created.' }
        format.json { render json: @batch, status: :created, location: @batch }
      else
        format.html {
          flash.now[:error] = @batch.errors.full_messages
          render action: "new"
        }
        format.json { render json: @batch.errors, status: :unprocessable_entity }
      end
    end
  end

      

after the index page is moved on the create action page without creating a folder. How to create a folder is created before going to the index page. Thanx in advance.

+3
ruby ruby-on-rails ruby-on-rails-3 google-drive-sdk google-api-ruby-client


source to share


No one has answered this question yet

Check out similar questions:

1998
How to write a switch statement in Ruby
1339
How can I rename a database column in Ruby on Rails migrations?
1165
Check if value exists in array in Ruby
1023
How do I get the current absolute url in Ruby on Rails?
978
What is attr_accessor in Ruby?
876
Brief explanation of nil v. Empty v. Blank in Ruby on Rails
771
How to get a random number in Ruby
2
ruby on rails has_many relation child validation form
1
Rails Dot to Url with two routes for one controller
-2
Could not find UserSession without ID in ruby โ€‹โ€‹on racks 3



All Articles
Loading...
X
Show
Funny
Dev
Pics