I need to add the following member methods to a number of resources, is there a way to DRY this up?
member do
get :votes
post :up_vote
post
Can't you just define a method in your routes files?
def foo
member do
get :votes
post :up_vote
post :down_vote
end
end
resources :news do
resources :comments do
foo
end
end
I haven't used this technique before. It just seemed to work when I did 'rake routes'. Anyways, the routes file is just Ruby code. Just be careful about the name of the method you define because it's defined in the instance of ActionDispatch::Routing::Mapper.
# routes.rb
MyApp::Application.routes.draw do
puts self
puts y self.methods.sort
end
# Terminal
> rake routes