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 8073349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:18:58+00:00 2026-06-05T14:18:58+00:00

Simple enough. When were making a typical restful rails app we would keep all

  • 0

Simple enough. When were making a typical restful rails app we would keep all routes inside of our applicaiton. Very rarely would a path link to an external path. But if we were to do it, I’m wondering what the best way is.

A typical matching of home

match "home"=>"appcontroller#home"

If we were matching an external url to a variable of path. We might do something like the below?

First method

Routes.rb

match "external"=>"http:/www.google.ie"

Then in our html.erb

<%= link_to 'Google', external_path %>

Note this is not actually a legal way of doing things but something similar may exist. It seems very close to the current way of defining paths in rails but with an external landing.

Second method

Something that I’ve seen done elsewhere is to create a global variable for the external URL and use it in the link. EG.
in environment.rb or production.rb or whatever

@ext_path="http:/www.google.ie"

Then in our html.erb

<%= link_to 'Google', @ext_path %>

So to recap. Whats the best way to use external URLS in rails. Paths? Variables? Other?
Any input appreciated

  • 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-05T14:19:01+00:00Added an answer on June 5, 2026 at 2:19 pm

    I would have kept external links only in views. Because this links are not related to the any kind of logic of the application, and it’s just an UI elements.

    So, this way seems to me the best:

    <%= link_to 'Google', "http://google.ie" %>
    

    If you need to use this element many times, maybe it makes sense to bring this code into the helper, for example:

    def search_engine_link
      link_to 'Google', "http://google.ie"
    end
    

    And I really think that is’s not very good place to introduce a more complex logic.

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

Sidebar

Related Questions

That seems simple enough, but all Django Queries seems to be 'SELECT *' How
I'm making a simple facebook canvas app (page tab) with PHP, that posts something
I'm making a very simple fishing game. the user has to buy pots, easy
Im currently making a very simple WebApp on a Website using ASP.NET Framework using
I'm making a simple app than needs to store a simple structure of data.
Simple enough question: I'm using python random module to generate random integers. I want
Simple enough question I am sure. Using MFC C++, what header do I need
Seems simple enough. I'm creating a search engine that returns results to the user
It is simple enough to put the outer text of an XML node in
This should seem simple enough, but can't figure it out. I was porting a

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.