Drawing routes using user name in Rails 3 w/ devise

前端 未结 2 638
一生所求
一生所求 2020-12-17 05:23

Given a one to many relationship between a user managed with devise and a \"thing\", my goal is to draw restful routes like:

http://host/username
http://host         


        
2条回答
  •  遥遥无期
    2020-12-17 05:46

    You can also use resource :user, path: ':id' do ... end

    Also don't forget to define to_param in your user modal & use User.find_by_username(params[:id]) in your controller.

提交回复
热议问题