← Back to Upcase

Letting users post link shouts

(Thomas Roest) #1

I’ve got to the part where users are able to post pictures and text shouts.But I would like them to be able to post (shortened) hyperlinks to external pages as well, what would be the best approach to do that? This would somehow involve manipulating the user input and returning it as a link…

(Ben Orenstein) #2

This question is very vague, so I’m not sure how to help you. Can you edit your post to add some clarifying details?

(Thomas Roest) #3

I have added some more info!

(Ben Orenstein) #4

Any thoughts here @halogenandtoast? I’m not familiar with the app in question.

(Matthew Mongeau) #5

@Thomas_Roest do you want existing text shouts to have links in them or do you want a new type of shout that has links. Either way you might want to take a look at the auto_link gem https://github.com/tenderlove/rails_autolink

(Thomas Roest) #6

thank you, I would like the text shouts to have links in them, so how would I use this gem in the shouter app?

(Matthew Mongeau) #7

Should be as simple as requiring the gem and then when you render a TextShout calling auto_link(text_shout.body)

(Thomas Roest) #8

Thank you for you reply! I wonder if you could help me with this situation.

I’m trying to shorten the links that are posted with bitly and the bitly gem.

To render the posts/shouts with links I used the following code ( auto_link gem).


I also managed to render a bitly url by using the bitly api and bitly gem;


Now I could not figure out how to automatically shorten the links that are posted, by replacing the hardcoded url. Is there a way to do this?