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

Is using collection option in rails routing means resources should be plural?

问题描述:

I was reading through the blog post Authentication with Warden, devise-less, but one thing in that post is how he approaches the routing. So which one is more logical:

the authors way

resources :users do

collection do

# Registrations is set as plural, which means that each user can make many

# registrations, and open many sessions and so will make many confiramtions

resource :registrations, only: [:show, :create]

resource :sessions, only: [:new, :create, :destroy]

resource :confirmations, only: [:show]

end

end

my way

resources :users do

collection do

# Their is only one registration for each user, so why we use it in plural

resource :registration, only: [:show, :create]

# the same with session and confirmation

resource :session, only: [:new, :create, :destroy]

resource :confirmation, only: [:show]

end

end

I am a little confused about the collection and member features in rails routing, so which one is more logical.

网友答案:

Since a resource more or less equals a controller in the Rails world and controllers should have plural names I would vote for the authors version.

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