Ruby on rails 3 Rails 3路由和名称空间
我最近继承了一个应用程序,其中用户的编辑帐户方法和公共帐户方法都位于同一个控制器中。我希望尝试让事情变得更“Rails风格”,以清理应用程序 以下是目前的路线Ruby on rails 3 Rails 3路由和名称空间,ruby-on-rails-3,routes,Ruby On Rails 3,Routes,我最近继承了一个应用程序,其中用户的编辑帐户方法和公共帐户方法都位于同一个控制器中。我希望尝试让事情变得更“Rails风格”,以清理应用程序 以下是目前的路线 resources :user, :only => [:update, :show] do member do get :edit_account put :edit_account put :update_billing_information put :update_acc
resources :user, :only => [:update, :show] do
member do
get :edit_account
put :edit_account
put :update_billing_information
put :update_account_type
get :edit_vitals
get :edit_videos
get :edit_athletic
get :edit_academic
get :edit_social
get :edit_news
get :edit_contributors
get :edit_primary_sport_positions
get :edit_primary_sport
get :edit_primary_sport_highlights
delete :remove_alternate_position
get :vitals
get :videos
get :athletic
get :academic
get :social
get :news
post :keep
post :draft
get :share
post :share
get :notes
post :notes
get :contact
post :contact
post :cut
delete :deactivate_account
delete :delete_authorization
end
get :change_current_sport, on: :collection
end
我想我要寻找的是,rails的最佳实践是什么?如果它们是用户使用嵌套资源的关联,那么将其移动到类似于
/user/edit/account
或/user/edit/billing
?。在我看来,这与你所说的相反,但它也更安静。@DaveNewton——你能给我举个例子吗?如果简化RESTful应用程序更多的是关于如何组织控制器和操作,那么用户有很多视频。这是一个关于这个主题的好报告。请记住,它对路由使用旧语法。