Doon
unread,Jul 9, 2010, 10:10:15 PM7/9/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TechValley Ruby Brigade
Just working on a small rails 3 App here, and playing with the new
router, and digging the new syntax...
Power::Application.routes.draw do |map|
resources :outlets , :only=>[:index,:show] do
member do
post :reboot, :on, :off
end
end
end
Wires it up this way..
reboot_outlet POST /outlets/:id/reboot(.:format)
{:controller=>"outlets", :action=>"reboot"}
on_outlet POST /outlets/:id/on(.:format)
{:controller=>"outlets", :action=>"on"}
off_outlet POST /outlets/:id/off(.:format)
{:controller=>"outlets", :action=>"off"}
outlets GET /
outlets(.:format)
{:controller=>"outlets", :action=>"index"}
outlet GET /
outlets/:id(.:format)
{:controller=>"outlets", :action=>"show"}
want to scope your admin stuff under /admin is as easy as..
namespace :admin do
match '/' => 'admin#index', :as=>:home
resources :pdus do
resources :outlets
end
resources :users
end
No real questions or the like, just happy that I hit 20 passing
scenarios on this project, and figured I would share :)
Have a good weekend..
-Doon