Back
Question
We're a group of makers shipping together. We help each other stay accountable and reach our goals.
Apply for accessGo to Homepage | g h |
Go to Done Todos | g d |
Go to Questions | g q |
Compose a New Todo | n |
Go to Search | / |
Show this dialog | ? |
👋 Join WIP to participate
When someone puts their email or url in the single input text field. The input will know which action to use whether to email or target blank the url. thanks
I’m not sure I fully understand the question. I’m assuming this is for Rails?
So you have a textfield where someone could enter either a URL or email address, and then based on what it is you want to generate the correct link?
You’d need to figure out a conditional that determines whether something is a URL or email address and then render it accordingly.
For example something like:
if @value.contains?(“@“)
mailto @value
else
linkto @value
end
This isn’t perfect because URLs could have @-signs in them, but you can use a method meant to check whether something is a correct URL/email. A simple Google search will return many results.
yes its for rails and yes i want to generate the correct link! right now i have two separate textfields --> it under one div <div>
<%= mail_to 'email', @post.email %>
or
<%= link_to 'website', @post.email %> </div> . Ah okay I'll look into it. Thanks WIPGod!
I figured it out :)