当前位置: 动力学知识库 > 问答 > 编程问答 >

"No route" ruby on rails routes

问题描述:

I want to change the name in routes file.

I have one controller called wiki_controller.

I am using another one which have same function as wiki named called FAQ which I don't have a controller.

usually the URL looks like

http://example.com/courses/1/wiki/front-page

I have another button called FAQ. When I click this link, the URL want to change like

http://example.com/courses/1/FAQ/front-page

but in the background the controller is wiki but the display URL must be the above.

网友答案:

You can create non-restfull routes like this:

get 'courses/:course_id/FAQ/:id', controller: 'wiki', action: :show

You can access the route by doing a GET request on /courses/1/FAQ/front-page, it will hit your wiki_controller#show

You can retrieve the variables with params[:course_id] and params[:id].

More details on non-restfull routes here

分享给朋友:
您可能感兴趣的文章:
随机阅读: