我有一个名为MeController
. 它有一堆动作,比如spaces
和projects
。
该spaces
操作执行以下操作:
def spaces
@spaces = current_user.spaces
respond_to do |format|
format.html # show.html.erb
format.json { render json: @note }
end
end
该视图仅呈现另一个索引模板,例如:
<%= render :template => "spaces/index" %>
这完美地工作,但现在奇怪的部分开始了......:S
这是project
动作:
def projects
@projects = current_user.projects
respond_to do |format|
format.html # index.html.erb
format.json { render json: @projects }
end
end
该视图还呈现一个索引模板:
<%= render :template => "projects/index" %>
但对于项目,我收到以下错误:
Routing Error
No route matches {:action=>"edit", :controller=>"spaces", :id=>nil}
我只是不明白为什么它应该是动作编辑和控制器空间的例行错误。:/
这是我的路线:
# Profiles & Current User
resources :profiles
get "me" => "profiles#show", :as => "current_user"
get "me/spaces", :as => "current_user_spaces"
get "me/projects", :as => "current_user_projects"
get "me/tasks", :as => "current_user_tasks"
get "me/notes", :as => "current_user_notes"
get "me/discussions", :as => "current_user_discussions"
get "me/files", :as => "current_user_files"
# Permissions
resources :permissions
resources :spaces do
resources :projects do
resources :tasks
resources :notes
end
end
devise_for :users
root :to => redirect("/me/spaces")
希望有人给我一个提示!:)