application_extension.rb 530 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. module ApplicationExtension
  3. extend ActiveSupport::Concern
  4. included do
  5. validates :name, length: { maximum: 60 }
  6. validates :website, url: true, length: { maximum: 2_000 }, if: :website?
  7. validates :redirect_uri, length: { maximum: 2_000 }
  8. end
  9. def most_recently_used_access_token
  10. @most_recently_used_access_token ||= access_tokens.where.not(last_used_at: nil).order(last_used_at: :desc).first
  11. end
  12. def confirmation_redirect_uri
  13. redirect_uri.lines.first.strip
  14. end
  15. end