新手问题 请教一个 Rails 的问题

levan · April 25, 2013 · 1863 hits

用 Devise 建立的用户注册登陆系统, 然后建立了一个Schoolscaffold, 问题就出在,当我没有登陆的时候,可以访问localhost:3000/schools

可是当登陆之后,再访问localhost:3000/schools的时候,就会显示 Routing Error No route matches {:action=>"show", :controller=>"users", :id=>nil}

然后试着在schoolscontroller#index里加多了一条:@user = current_user 然后localhost:3000/schools就可以访问了,但也只是 index 而已。

问题是为什么会这样?school scaffold 是单独建立的,还没跟 user 建立关系

下面是我的 routes.rb

App01::Application.routes.draw do
    devise_for :users, :controllers => {:registrations => "registrations"}

    resources :schools
    resources :users do 
        resources :albums
        resources :photos
    end

    root :to => "home#index"
end
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.