Internally, link_to
calls url_for
to get the path for the given arguments.
If you call url_for
with a model, it'll forward further to polymorphic_path
or polymorphic_url
.
So something like this should work, if you just want the path
task :some_task => :environment do
include Rails.application.routes.url_helpers
# ...
path = polymorphic_path(some_model_instance) # => e.g. "/widgets/42"
end
You can also just use url_for
, but you'll have to define the :host
option. See here for more