我有一个Rails控制器用于测试目的:
class MyTestController < ApplicationController
skip_before_action :verify_authenticity_token
def test1
end
def test2
end
def test3
end
def test4
end
def test5
end
........
end
以及以下路线:
get '/my_test/test1', to: 'my_test#test1'
get '/my_test/test2', to: 'my_test#test2'
get '/my_test/test3', to: 'my_test#test3'
get '/my_test/test4', to: 'my_test#test4'
get '/my_test/test5', to: 'my_test#test5'
........................................
如何为此控制器的每个未来公共方法创建一个路由,以排除每个方法添加一个路由的需要?
答案 0 :(得分:5)
这应该有效:
get '/my_test/:action', controller: 'my_test'