HI I am working on a rails application. I want to implement user tagging as facebook or twitter does. When user is posting in feed he can tag any user with @ character at starting.
I am using Jquery UI Autocomplete plugin.
I have this reference
Implementing jquery UI autocomplete to show suggestions when you type "@" which helped me to implement auto complete part.
But now I want to link that auto completed username to users profile url e.g Username = Mak then link should be generated like
<a href="http://www.example.com/username">Username</a>
So please guide me how can I implement this in my rails application?Is there any gem to do so.
Hey it doesn’t required above methods. I did it using simple regex.
In my regex I have used
(\^|\s|\B)because @ can occur at start of string or after a white space while tagging a user.([a-zA-Z])(_?[a-zA-Z0-9]+)*|_([a-zA-Z0-9]+_?)*This is used to validate username. In my application username must start with alphabet followed by alphabets & numbers.The no. 2 used to take second match in regex.
For more details try the regex on Rubular.com
I hope this will help others.