Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:52:22+00:00 2026-06-09T00:52:22+00:00

Currently when a user in my app creates a new job post they enter

  • 0

Currently when a user in my app creates a new job post they enter a URL that links to their job page on their website. I then want to use this to link out to their site.

It is stored in my DB asjob.job_url and I have defined an object @link in my controller to find the job and relevant URL.

I currently have the following code to loop through all jobs and provide links:

 <section id="job-wrapper">
   <% @jobs.each do |job| %>
    <%= link_to @link.job_url do %>
       <%= job.title %>
       <%= job.location %>
       <%= job.job_type %>
       <%= job.salary %>
       <%= job.company %>
   <% end %>
  <% end %>
 </section>

The issue I am having is that without the URL containing http:// rails assumes that the link is internal and so produces a link like localhost:3000/www.google.com.

Is there a way for me to ensure Rails only ever recognises the link as external in the instance? Alternatively could someone explain how I can add http:// to all links on creation unless the user has already stated it?

Thanks in advance for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:52:24+00:00Added an answer on June 9, 2026 at 12:52 am

    Thanks for all your help!

    I managed to solve this by creating a new helper called URLhelper

    This contained:

     module UrlHelper
       def url_with_protocol(url)
         /^http/.match(url) ? url : "http://#{url}"
       end
     end
    

    I then just used the following link_to

     <%= link_to url_with_protocol(@link.job_url), :target => '_blank' do %>
    

    Thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on an app that lets the user choose an MP3 audio
I'm currently working on an app that allows the user to draw pixelated images
A new question about android and services. Currently I'm developing a App that should
Currently I have a Rails 3 app that subscribes new users up to MailChimp.
Currently, My Rails (3) app creates objects before their relation is known (I store
I have a rails app which currently has 3 models: Post , User and
I'm currently working on an app that allows the user to play (automatically scroll)
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
I'm currently implementing a user registration for an app. I'm tying to change the
I'm currently supporting a Python web app with increasingly complicated user/role/permission management requirements. Currently,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.