2011-05-17 119 views
1

我得到加载页面时,此路由错误:路由错误当路由存在

ActionController::RoutingError in Videos#index 

Showing /rubyprograms/dreamstill/app/views/layouts/application.html.erb where line #26 raised: 

No route matches {:action=>"show", :controller=>"profiles"} 

它指的是这一行:

<%= link_to "Profile", profile_path(current_user.profile), :class => 'normal' %> 

然而,路线的存在是因为我有这我的路线:

resources :profiles do 
    get 'activity', :on => :member 
    get 'shown_songs', :on => :member 
end 

,我有我的配置文件控制这个动作:

def show 
    @profile = Profile.find(params[:id]) 
end 

这是怎么回事,我该如何解决这个问题?

回答

2

如果你将一个零对象传递给你的url助手,你会看到这个错误。检查current_user.profile在这一行中是否为零:

profile_path(current_user.profile)