Jerome
Jerome

Reputation: 6217

accessing route helper in a method

When preparing a connection to the Twilio API

 def send_text(user, message)
    client.api.account.messages.create(
      to: user.telefono_mobile,
      from: phone_number,
      status_callback: update_twilio_reminder_url.to_s,
      body: message
    )
  end

The callback for the message status must be a url. However this syntax does not access rails's helper method and returns the error undefined local variable or method 'update_twilio_reminder_url'

What is the proper syntax?

Upvotes: 0

Views: 21

Answers (1)

blazpie
blazpie

Reputation: 312

have you tried to include Rails.application.routes.url_helpers in controller? in newer rails (5 I guess) its also enough to call helper method by helpers.helper_method but I never tried it.

Upvotes: 1

Related Questions