views:

24

answers:

1

I am surprised I couldn't find it on google, what's the best way to add a "tweet" this link to post a url and a description to the user's twitter account?

+1  A: 

The 'tweet this link' feature is extremly simple and does not require additional Rails features. It is as simple as:

<a href=http://twitter.com/home?status=Name_and_Address_of_the_twitter_post_that_you_want_everyone to_see_on_twitter>Add to Twitter</a>

To use Rails code, it would be something like:

= link_to "tweet me", "http://twitter.com/home?status=#{@post.short_name} #{post_url(@post)}"

Some remarks:

  • the status should not be bigger than 140 chars (you can use either an external service as bit.ly or you can write your own controller that answers to small addresses and that redirects to the post)

  • you can also implement a tracking mechanism that could detect how many users clicked on the 'tweet this' link

Vlad Zloteanu
Thanks. Yes I also meant the link with tracking, just like digg does it with a javascript include
badnaam