ruby on rails - Nesting namespace and missing template -


i trying implement administration panel , thought nice have links different tabs on left side of screen , display tabs on right side of screen using ajax.

i decided go :admin namespace within model resources (as need :id) did in router.rb:

resources :my_model     namespace :admin         "panel", to: "panel#index" #the route display main admin panel view         # let assume have 1 tab:         namespace :info_tab             "index", to: "info_tab#index"         end     end end 

then in controllers files have hierarchy this:

controllers/admin/info_tab/info_tab_controller.rb

within file wrote (which not sure if did right)

class  admin::infotab::infotabcontroller < applicationcontroller     def index         logger.debug("index info_tab_controller loaded!")         respond_to |format|             format.js         end     end end 

i implemented remote: true link tab , after click method controller gets executed, in server logs this:

started "/my_model/1/admin/info_tab/index" ::1 @ 2016-11-10 22:33:55 +0100 processing admin::infotab::infotabcontroller#index js no template found admin::infotab::infotabcontroller#index, rendering head :no_content completed 204 no content in 69ms (activerecord: 0.4ms) 

my index view infotabcontroller places under:

views/admin/info_tab/index.js.erb 
  1. what did wrong?

  2. is approach trying right? or there better way structure it? (especially routes)

rails looks view paths based on

/app/views/{namespace1}/{namespace2}/{controller}/{action}

so assume you'd need view path

app/views/admin/info_tab/info_tab/index.*

unless anticipate many different infotab controllers (like, dozens), recommend removing infotab namespace, controller is: admin::infotabcontroller < applicationcontroller in case current view path should work.

if want more info on how rails looks view paths, i'd checkout blog post https://climber2002.github.io/blog/2015/04/06/digging-rails-how-rails-finds-your-templates-part-4/


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -