To Examples

AddAction Example

Directions

  1. Complete the NestedRoutes Example before working on this example.
  2. To the folder NestedRoutes/app/views/owners add this new view: summary.html.erb.
  3. In the routes file NestedRoutes/config/routes.rb, change
     resources :owners do
      resources :pets
    end
    
    to
     resources :owners do
      resources :pets
      collection do
        get :summary
      end
    end
    
  4. Add this method to AddAction/app/controllers/owners_controller:
    def summary
      @owners = Owner.all
    end
    
  5. Localhost URL to view summary view:
    http://localhost:3000/box_model/page1