This project is archived and is in readonly mode.

#6677 ✓invalid
Rafael Felix

Namespace and Custom routes

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

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

Comments and changes to this ticket

  • Andrew White

    Andrew White April 6th, 2011 @ 06:53 AM

    • 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?

  • Rafael Felix

    Rafael Felix April 6th, 2011 @ 12:22 PM

    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

  • Andrew White

    Andrew White April 6th, 2011 @ 05:57 PM

    Do you have an Admin::Dashboard model?

  • Rafael Felix

    Rafael Felix April 6th, 2011 @ 06:13 PM

    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

  • Andrew White

    Andrew White April 7th, 2011 @ 09:35 AM

    Can you post a backtrace?

  • Rafael Felix

    Rafael Felix April 8th, 2011 @ 04:07 AM

    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)

  • bill
  • Andrew White

    Andrew White April 11th, 2011 @ 05:41 PM

    • State changed from “needs-more-info” to “invalid”

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages