ruby on rails - How to make a concern route DRYer -
sometimes need concern route collection , member (sometimes have_many
galleries, , has_one
)
concern :single_galleriable resource :gallery, concerns: :photoable member post :make_feature end end end concern :galleriable resources :gallery, concerns: :photoable member post :make_feature end end end
and do
resources :somemodel, concerns: :single_galleriable
obviously, wet..
can use concern resource or resources according needs while concern's content stay same?
don't know if help, can use methods in routes.rb file:
#config/routes.rb (some of our actual code) #methods have kept @ top def destroy_all collection delete :destroy_all delete 'destroy(/:id)', action: 'destroy', as: 'multi_destroy' end end #general stuff resources :controller destroy_all end
--
this means this:
#config/routes.rb #methods have kept @ top def gallery type = true method = type ? "s" : "" self.send("resource#{method}") :gallery, concerns: :photoable post :make_feature end end #general resources :controller gallery false end
Comments
Post a Comment