Guest User

Untitled

a guest
Jun 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. # config/routes.rb
  2.  
  3. map.resources :companies, :has_many => :branches, :collection => {:all => :get}
  4.  
  5. # app/controllers/companies_controller.rb
  6.  
  7. # this assumes you have a boolean column defining main in the branches table
  8. def show
  9. @company.find(params[:id])
  10. @branch = @company.branches.scoped_by_main(true)
  11. end
  12.  
  13. def all
  14. @company = Company.find(params[:id])
  15. end
Add Comment
Please, Sign In to add comment