使用更改的ID设置根路由

时间:2018-09-25 04:36:35

标签: ruby-on-rails

我想拥有:example.com/123,其中123可以是任何字符串。

如何设置根路由来处理此问题?

我正在使用get,但这不是根目录。我看不到如何包含该specid

get('/:specid' => 'outlets/dance#index', :as => :dance)

1 个答案:

答案 0 :(得分:0)

应指定根。您可以重定向到显示页面。例如,root 'employees#show', {id: 1}。这可能对您有帮助。 或者,如果您希望在url中使用params字符串,则可以像这样在roots文件中建立根目录,让它在root之后重定向。 root to: 'dashboard#index', to: redirect('/company_structures/3')。它将像http://localhost:3000/company_structures/3

那样输出
相关问题