I have a method inside of my message model for creating a notification and when the notification is created I'm also creating the contents for a string variable content. This is what the method looks like.
def create_notification
if self.conversation.sender_id == self.user_id
sender = User.find(self.conversation.sender_id)
Notification.create(content: "New message from #{sender.fullname}", user_id: self.conversation.recipient_id)
else
sender = User.find(self.conversation.recipient_id)
Notification.create(content: "New message from #{sender.fullname}", user_id: self.conversation.sender_id)
end
end
I would like to make the content "New message from #{sender.fullname}" all a link to converstations_path. I have tried the following.
Notification.create(content: "<a href="/converstions">New message from #{sender.fullname}</a>", user_id: self.conversation.recipient_id)
also
Notification.create(content: "<%= link_to 'New message from #{sender.fullname}', conversations_path %>", user_id: self.conversation.recipient_id)
The result is it will render everything inside of the quotation marks ignoring the html or the link_to helper. How can I make this a link?
I am rendering the notification.content inside of my _notification.html.erb this is what the file looks like
<strong><%= notification.content %></strong>
<span class="pull-right"><%= notification.created_at.to_formatted_s(:short) %></span>