metikular
  • Home
  • Products
  • Services
  • Know-How
  • Blog
  • About us
  • en
        • Stimulus/Turbo JavaScript error
        • Drop multiple tables
          • Allow login
          • Check access rights
          • Grant access
        • Copy database
        • psql commands
        • Show table schema
          • Find devise user in channel
          • Own not found page
          • Raise 404 in controller
          • Stream response
          • Helpers
          • Send email from console
            • Submit labels
            • Set default_url_options
          • Cancel link
          • Check if view exists
          • Default template engine for generators
          • Inline assets with propshaft
          • Passing variables to views
          • Render a Markdown string
          • Render outside request
          • Attribute types
          • Validate array inclusion
          • Validate date in range
          • Validate email address
          • Validate url
            • Check for value in array
            • Concurrent index
            • Create array in postgres
            • Get Postgres version from Rails console
            • Index name too long
            • Is string null or empty?
            • Select attribute within JSONB
            • Execute SQL query
          • Change default value in migration
          • Check database configuration
          • Create join table
          • Different database systems
          • Find models without associated models
          • Foreign key to differently named table
          • Unique index on multiple columns
          • Zero downtime migrations
          • Attach file
          • Migrate documents from S3 to local storage
          • MinIO configuration
          • Sanitize filename
          • Change date parts
          • Sign URLs
            • Login user if possible
            • Redirect on access denied
            • Duration methods
          • Parse a boolean
            • Show whole backtrace
          • Fallbacks
          • Set current locale
          • Rake task with arguments
          • Scope controller below a parent one
          • Automatic form submission
          • Turbo.visit with stream
        • Ensure Rails is loaded in an initializer
          • Screenshots on Github Actions
          • Different return values
          • Stub unverified method
        • Attach file with capybara
        • Check that email was sent
        • Define route within spec
        • Expect a job to be enqueued
        • Expect within epsilon
        • File fixtures
        • Find link by text in e-mail
        • Find WebMock requests
        • Inspect test data in database
        • not_change matcher
        • Run without a type
        • Stub Rails.env
        • Use `dom_id` in a spec
          • Redefine class
        • Bundle gems into vendor
        • Call super of super
        • Catch signal from Ctrl-c
        • eql and equality operators
        • Local Gemfile
        • Method definition on one line
        • Pass options to to_csv
        • Root URL
        • Source location of class or module
        • Source location of method
        • Use standard confing for Rubocop
    Home

    ❯

    rails

    ❯

    active_model

    Validate url

    Mar 14, 2025

    validates :my_url, format: {with: URI::DEFAULT_PARSER.make_regexp}, if: proc { |o| o.my_url.present? }

    Or, with the gem https://github.com/perfectline/validates_url

    validates :my_url, url: { allow_blank: true }