我设置了edit_path来编辑客户,它运行正常。但是,由于某些旧版权限授权问题,我需要为客户使用不同的命名约定,因此我的权限名为action_company
而不是action_customer
。我需要能够使用像edit_company_path
这样的路径,但我不确定如何让它工作,我不断获得undefined method 'edit_company_path'
。我试过搞乱这些路线,但我明显误解了Rails如何将路径映射到行动。
如何将此自定义路径别名映射到客户的正确编辑操作?
答案 0 :(得分:0)
未定义的方法'edit_company_path'
如果您要为现有编辑路径设置别名,请使用as:
。像下面的东西
#routes.rb
get '/edit/:id', to: 'controller#edit', as: :edit_company
这将是您可以使用的所需路线助手。