Rails.application.routes.draw do crm_path = 'admin/crm' scope :path => crm_path, :module => :e9_crm do resources :companies, :except => :show resources :contacts, :except => :show do resources :page_views, :path => 'activity', :only => :index collection { get :templates } end resources :deals, :except => :show resources :offers, :except => :show # contact_emails are generated by email templates, and end up in the sent emails list resources :contact_emails, :except => [:index, :show] resources :email_templates, :except => :show resources :menu_options, :except => [:show] do collection { post :update_order } end # campaigns_controller only handles index, the individual controllers all support # specific index views and manage create/edit/destroy resources :campaigns, :only => :index do resources :page_views, :path => 'activity', :only => :index end scope :path => :campaigns do get '/activity', :to => redirect("/#{crm_path}/campaigns/all/activity") resources :campaign_groups, :path => 'groups', :except => [:show] resources :sales_campaigns, :path => 'sales', :except => [:show] resources :advertising_campaigns, :path => 'advertising', :except => [:show] do resources :dated_costs, :path => 'costs' end resources :affiliate_campaigns, :path => 'affiliate', :except => [:show] resources :email_campaigns, :path => 'email', :except => [:show] end # leads are simply a scoped view of offers (only index) get :leads, :as => :leads, :to => 'deals#leads' get :marketing_report, :to => 'campaigns#reports', :only => :index get '/merge_contacts/:contact_a_id/and/:contact_b_id', :as => :new_contact_merge, :to => 'contact_merges#new' post '/merge_contacts', :as => :contact_merges, :to => 'contact_merges#create' # redirect shows to edits %w( campaigns/advertising campaigns/affiliate campaigns/email campaigns/sales campaigns/groups contacts deals email_templates menu_options offers ).each do |path| get "/#{path}/:id", :to => redirect("/#{crm_path}/#{path}/%{id}/edit"), :constraints => { :id => /\d+/ } end end end