Class: PlaidRails::LinkController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PlaidRails::LinkController
- Defined in:
- app/controllers/plaid_rails/link_controller.rb
Instance Method Summary collapse
Instance Method Details
#authenticate ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/plaid_rails/link_controller.rb', line 6 def authenticate begin @exchange_token = Plaid.exchange_token(link_params[:public_token]) @params = link_params.merge!(token: link_params[:public_token]) rescue => e Rails.logger.error "Error: #{e}" Rails.logger.error e.backtrace.join("\n") render text: e., status: 500 end end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/plaid_rails/link_controller.rb', line 19 def update begin exchange_token = Plaid.exchange_token(link_params[:public_token]) @accounts =PlaidRails::Account.where(owner_type: link_params[:owner_type], owner_id: link_params[:owner_id]) @accounts.each do |account| account.update(access_token: exchange_token.access_token) end flash[:success]="You have successfully updated your account(s)" rescue => e Rails.logger.error "Error: #{e}" Rails.logger.error e.backtrace.join("\n") render text: e., status: 500 end end |