Overriding a resource route to / (root) in Rails3: not changing the path helper?

笑着哭i 提交于 2019-12-03 06:24:24

Thank you for your answers, it helped me find the exact solution to my question:

resources :subscribers, :only => [:new, :create], :path => '', :path_names => {:new => ''}

Tested and working on Rails 3 :)

You could do

resources :subscribers, :path => ''

and make sure that GET / is being served by your root template, e.g. by adding this to SubscribersController:

  def index
    render 'welcome/index'
  end

I experimented with using a match "/" declaration to override the resource index action and map it to another controller instead but apparently a resources declaration is always fully overriding manually declared routes.

For number 2 in your list, delete this line, and rewrite any _path or _url methods in your erb:

resources :subscribers, :only => [:new, :create]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!