I encountered a similar situation, so I created a view helper. For your case, I think you can do something like this.
helpers/application_helper.rb:
def custom_path pathvar
if pathvar == 'foo'
new_foo_path
elsif pathvar == 'bar'
new_bar_path
end
end
, , :
= link_to custom_path(bar), class: 'source card' do
. .