Finally I got it how to do it. The problem was that using release_path it returns the current path, the symlink and not the actual path. So I got to that searching the internet.
# file: lib/capistrano/tasks/rvmrc.cap
namespace :rvmrc do
desc "Trust rvmrc file"
task :trust do
on roles(:app) do
releases = capture("ls #{File.join(fetch(:deploy_to), 'releases')}")
if this_host_last_release = releases.split("\n").sort.last
execute "~/.rvm/bin/rvm rvmrc trust #{releases_path}/#{this_host_last_release}"
end
end
end
end
# file: deploy.rb, in the end
after :finishing, 'rvmrc:trust'