I've got a nested resource:
def workspace
has_many :instances
end
def instance
belongs_to :workspace
end
and some nested routes
resources :workspaces do
resources :instances do
end
end
resources :instances
That way, I can visit the following path and get the same result:
workspaces/1/instances
/instances
On my 'view/instances/index.html.erb' I have a custom pagination link, where I reload the page with additional params.
If I am in workspaces/1/instances, the link should be:
= link_to "← Previous", workspace_instances_path(:param => "data")
But, if I am in /instances:
= link_to "← Previous", instances_path(:param => "data")
How can I have a single link_to, that works for both routes? Preferably without listing all possible cases, just a single line