DavidM
DavidM

Reputation: 173

How to customise the url for the root path?

My current root gives a url in the form: www.project.com/taskforce

But I would like the url to be: www.project.com/taskforce/dashboard

I thought I could achieve this by adding: root to: "dashboard#index", path: "taskforce/dashboard"

But I get the following error: Ambiguous route definition. Both :path and the route path were specified as strings.

My routes are as follows:

module TaskForceRoutes
  def self.extended(router)
    router.instance_exec do
      namespace :taskforce do
        root to: "dashboard#index"
        get :new_group_runners, to: "dashboard#new_group_runners", path: "new-group-runners"
        get :members_not_running_much, to: "dashboard#members_not_running_much", path: "members-not-running-much"
        get :attendance_stats, to: "dashboard#attendance_stats", path: "attendance-stats"
        get :area_heroes, to: "dashboard#area_heroes", path: "area-heroes"
        get :resign, to: "dashboard#resign", path: "resign"
      end
    end
  end
end

And I've got a Taskforce::DashboardController

Upvotes: 0

Views: 203

Answers (1)

Max Vinicius
Max Vinicius

Reputation: 647

Try this:

# routes.rb

scope 'taskforce/dashboard' do
  root to: "dashboard#index"
end

Source: https://guides.rubyonrails.org/routing.html

Upvotes: 1

Related Questions