<%= form_for [current_user, @task] do |f| %>
gives users/:id/tasks
but I would need users/:slug/tasks
as I am using:
resources :users, param: :slug do
resources :tasks, only: [:index, :new, :create]
end
but if I use:
<%= form_for [current_user.slug, @task] do |f| %>
I get: NoMethodError: undefined method 'jemelle_visits_path' for
how to get users/jemelle/tasks
instead?
I think you need to override the
to_param
method of your model:https://apidock.com/rails/ActiveRecord/Base/to_param