Guest User

Untitled

a guest
Jul 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. map.resources :users
  2. #map.resources :companies, :has_many => :regions
  3. #map.resources :regions, :has_many => :locations
  4. map.resources :companies do |companies|
  5. companies.resources :regions do |regions|
  6. regions.resources :locations do |locations|
  7. locations.resources :sales
  8. end
  9. end
  10. end
  11.  
  12.  
  13. ## Regions controller
  14.  
  15. def create
  16. @company = Company.find(params[:company_id])
  17. @region = @company.regions.build(params[:region])
  18.  
  19. respond_to do |format|
  20. if @region.save
  21. flash[:notice] = 'Region was successfully created.'
  22. format.html { redirect_to company_region_url(@company, @region) }
  23. format.xml { render :xml => @region, :status => :created, :location => @region }
  24. else
  25. format.html { render :action => "new" }
  26. format.xml { render :xml => @region.errors, :status => :unprocessable_entity }
  27. end
  28. end
  29. end
Add Comment
Please, Sign In to add comment