2014-08-31 28 views
2

我有一个项目,用户可以下载文件。现在,我需要另一个页面来显示所有用户。所以,我在我的addfiles_controller中添加了一个方法all_users。我也有一个观点页面all_users.html.erb。但是这个问题与routes.rb文件有关。这里我想确保用户只能使用:index, :new, :create, :destroy, :all_users路径。 如何设置这样的:只在我的routes.rb文件的帮手,就像使用:只有帮手在路线

resources :addfiles, only: [:index, :new, :create, :destroy, :all_users] 

我的routes.rb文件::

resources :addfiles do 
    collection do 
     get 'all_users' 
    end 
    end 

回答

1

你不应该写all_usersonly,因为only/except相关只是标准动作index, show, new, edit, create, update, destroy其中resources默认定义为

resources :addfiles, only: [:index, :new, :create, :destroy] do 
    collection do 
     get 'all_users' 
    end 
    end 
+0

非常感谢。 – Mezbah 2014-08-31 14:30:08