Reputation: 2907
How can I make a controller restful when it does not have a model? I have the following controller called programs, and I want it to be restful so that:
rake routes | grep programs
will show me a complete list of methods. Currently I only have:
new_programs GET /programs/new(.:format) {:controller=>"programs", :action=>"new"}
edit_programs GET /programs/edit(.:format) {:controller=>"programs", :action=>"edit"}
programs GET /programs(.:format) {:controller=>"programs", :action=>"show"}
PUT /programs(.:format) {:controller=>"programs", :action=>"update"}
DELETE /programs(.:format) {:controller=>"programs", :action=>"destroy"}
POST /programs(.:format) {:controller=>"programs", :action=>"create"}
I have added map.resource :programs to my routes file, I want /program/:id as well
Upvotes: 0
Views: 428
Reputation: 47548
I think you've used resource
when you needed to use resources
. Try changing your routes to:
map.resources :programs
Upvotes: 1
Reputation: 10400
You are going off the definition here. But it is possible. model is not necessary.just create the resources line and create the controller. Inside the controller's actions, define the code you want to put.
Upvotes: 0