Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # config/routes.rb
- map.resources :companies, :has_many => :branches, :collection => {:all => :get}
- # app/controllers/companies_controller.rb
- # this assumes you have a boolean column defining main in the branches table
- def show
- @company.find(params[:id])
- @branch = @company.branches.scoped_by_main(true)
- end
- def all
- @company = Company.find(params[:id])
- end
Add Comment
Please, Sign In to add comment