Hi,

I am wondering if there is any refactoring possible in the following
routes as there seems to be a lot of redundancy in the code.  I am
learning on my own so the answer may be obvious and I appreciate the
help.


# Routes for navigating contents:
 #Books
  get 'contents/index_books/:subject_id',                   to:
'contents#index_books',            :as => :index_books
  get 'contents/:id/edit_book',                             to:
"contents#edit_book",              :as => :edit_book
  patch 'contents/:id/update_book',                         to:
"contents#update_book",            :as => :update_book
  get 'contents/:subject_id/new_book',                      to:
"contents#new_book",               :as => :new_book
  post 'contents/create_book',                              to:
"contents#create_book",            :as => :create_book
  delete 'contents/:id/destroy_book',                       to:
"contents#destroy_book",           :as => :destroy_book

 #Chapters
  get 'chapters/index_chapters/:book_id',                   to:
'contents#index_chapters',         :as => :index_chapters
  get 'contents/:id/edit_chapter',                          to:
"contents#edit_chapter",           :as => :edit_chapter
  patch 'contents/:id/update_chapter',                      to:
"contents#update_chapter",         :as => :update_chapter
  get 'contents/:book_id/new_chapter',                      to:
"contents#new_chapter",            :as => :new_chapter
  post 'contents/create_chapter',                           to:
"contents#create_chapter",         :as => :create_chapter
  delete 'contents/:id/destroy_chapter',                    to:
"contents#destroy_chapter",        :as => :destroy_chapter

 #Sections
  get 'contents/index_sections/:chapter_id',                to:
"contents#index_sections",         :as => :index_sections
  get 'contents/:id/edit_section',                          to:
"contents#edit_section",           :as => :edit_section
  patch 'contents/:id/update_section',                      to:
"contents#update_section",         :as => :update_section
  get 'contents/:chapter_id/new_section',                   to:
"contents#new_section",            :as => :new_section
  post 'contents/create_section',                           to:
"contents#create_section",         :as => :create_section
  delete 'contents/:id/destroy_section',                    to:
"contents#destroy_section",        :as => :destroy_section

 #Subsections
  get 'contents/index_subsections/:section_id',             to:
"contents#index_subsections",      :as => :index_subsections
  get 'contents/:id/edit_subsection',                       to:
"contents#edit_subsection",        :as => :edit_subsection
  patch 'contents/:id/update_subsection',                   to:
"contents#update_subsection",      :as => :update_subsection
  get 'contents/:section_id/new_subsection',                to:
"contents#new_subsection",         :as => :new_subsection
  post 'contents/create_subsection',                        to:
"contents#create_subsection",      :as => :create_subsection
  delete 'contents/:id/destroy_subsection',                 to:
"contents#destroy_subsection",     :as => :destroy_subsection

 #Minisections
  get 'contents/index_minisections/:subsection_id',         to:
"contents#index_minisections",     :as => :index_minisections
  get 'contents/:id/edit_minisection',                      to:
"contents#edit_minisection",       :as => :edit_minisection
  patch 'contents/:id/update_minisection',                  to:
"contents#update_minisection",     :as => :update_minisection
  get 'contents/:subsection_id/new_minisection',            to:
"contents#new_minisection",        :as => :new_minisection
  post 'contents/create_minisection',                       to:
"contents#create_minisection",     :as => :create_minisection
  delete 'contents/:id/destroy_minisection',                to:
"contents#destroy_minisection",    :as => :destroy_minisection
Dave

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/42d0ad2d547cff3509781eecaa292f96%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to