2

I am getting an array with a single element in it, ["http://i.foobar.com/This-Is-The-Remainder-Of-The-Link.jpg"] and I'm trying to render it as just the URL to display an image. Any thoughts on the best way to do this? Currently when I render it in HTML I get ["http://i.foobar.com/This-Is-The-Remainder-Of-The-Link.jpg"]

3
  • 2
    Umm, what's wrong with a[0] or a.first? Commented Jun 27, 2012 at 3:43
  • You need to provide more information. the "&quote;" is HTML escaping of the quote character. What is doing this escaping? (ERB in Rails?) You need to know this, because the proper way to solve this is something like "<img src='#{a.first}' />" but if the quote is escaped, then the HTML characters will be, too, so this will display in your page as text rather than being interpreted as code. (If you're in Rails, its best to use their url helpers like image_tag) Commented Jun 27, 2012 at 4:42
  • ERB in Rails is doing the escaping on this. Commented Jun 27, 2012 at 15:31

1 Answer 1

8

You should just be able to pull the first element. You can do this by doing the following.

a = ['http://someurl.com/somepath']
a.first

or

a = ['http://someurl.com/somepath']
a[0]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.