If you want your code to be evaluated use <%
. <%=
is for writing stuff out on the page.
Also the .send_message method really shouldn't be in your view. Create an action in your controller, or create whole service object and make it responsible for messaging.
One thing is that code like this really doesn't belong in a view. But more importanlty, you should be calling it, only if user click a link. So, simple solution would be:
- create an action 'send_message' in one of your controllers
- create a route for this action
- put the line
current_user.send_message(@user, "Body", "subject")
into your newly created action, use redirect if you don't want a template for this action - and in your view add a link (or button), to this action