Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Namespace and Custom routes

#6677

Given the following routes

  namespace :admin do
    root :to => "dashboard#index"
  end

the rake routes return
admin_root /admin(.:format) {:controller=>"admin/dashboard", :action=>"index"}

the Admin::DashbordController has only the index method.

when I go to localhost:3000/admin I'm getting 'uninitialized constant Dashboard'

I've tried to use match 'admin' => "admin/dashboard#index" getting the same error message...

I'm running rails 3.0.6

Reported by Rafael Felix · April 6th, 2011 @ 04:30 AM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • State changed from new to needs-more-info
    • Importance changed from to Low

    Works in a brand new 3.0.6 app for me - are you sure your controller names are correct?

    April 6th, 2011 @ 06:53 AM

  2. Rafael Felix
    Rafael Felix

    Andrew, I think the name is ok

    take a look (it's inside app/controllers/admin

    file name dashboard_controller.rb

      class Admin::DashboardController < Admin::AdminController
        load_and_authorize_resource
        def index
        end
      end
    

    and the Admin::AdminController (admin_controller.rb)

      class Admin::AdminController < ApplicationController
        layout 'admin'
        before_filter :authenticate_user!
      end
    

    best regards
    Rafael

    April 6th, 2011 @ 12:22 PM

  3. Andrew White
    Andrew White

    Do you have an Admin::Dashboard model?

    April 6th, 2011 @ 05:57 PM

  4. Rafael Felix
    Rafael Felix

    No, I don't have any

    I don't know if it helps, but the authentication is provided by devise, and the load_and_authorize_resource is from CanCan

    April 6th, 2011 @ 06:13 PM

  5. Andrew White
    Andrew White

    Can you post a backtrace?

    April 7th, 2011 @ 09:35 AM

  6. Rafael Felix
    Rafael Felix

    at the first time, before_filter send me to the login

    Started GET "/admin" for 127.0.0.1 at 2011-04-08 00:03:17 -0300
    SQL (60.1ms) SHOW client_min_messages SQL (0.9ms) SET client_min_messages TO 'panic' SQL (0.8ms) SET standard_conforming_strings = on SQL (1.6ms) SET client_min_messages TO 'notice' SQL (62.6ms) SET time zone 'UTC' SQL (1.0ms) SHOW TIME ZONE Processing by Admin::DashboardController#index as HTML Completed in 3ms

    Started GET "/users/sign_in" for 127.0.0.1 at 2011-04-08 00:03:19 -0300
    Processing by Devise::SessionsController#new as HTML SQL (327.9ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum

    Rendered devise/shared/_links.erb (6.6ms)
    Rendered devise/sessions/new.html.erb within layouts/application (347.7ms)
    Completed 200 OK in 1058ms (Views: 493.8ms | ActiveRecord: 454.9ms)

    after the devise login

    Started GET "/admin" for 127.0.0.1 at 2011-04-08 00:07:17 -0300
    Processing by Admin::DashboardController#index as HTML SQL (48.3ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum User Load (8.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 SQL (3.3ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum Completed in 546ms

    NameError (uninitialized constant Dashboard):

    Rendered /home/suerafa/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/trace.erb (2.1ms)
    Rendered /home/suerafa/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/
    request_and_response.erb (155.2ms)
    Rendered /home/suerafa/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (167.4ms)

    April 8th, 2011 @ 04:07 AM

  7. bill
  8. Andrew White
    Andrew White
    • State changed from needs-more-info to invalid

    Your problem is CanCan - it's trying to authorise the Dashboard resource which doesn't exist

    April 11th, 2011 @ 05:41 PM