Reputation: 4004
I get this routing error when loading the page:
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"}
It is referring to this line:
<%= link_to "Profile", profile_path(current_user.profile), :class => 'normal' %>
However, the route exists because I have this in my routes:
resources :profiles do
get 'activity', :on => :member
get 'shown_songs', :on => :member
end
and I have this action in my profiles controller:
def show
@profile = Profile.find(params[:id])
end
What's going on and how can I fix this?
Upvotes: 1
Views: 1115
Reputation:
If you're passing a nil object to your url helper, you will see this error. Check that current_user.profile isn't nil in this line:
profile_path(current_user.profile)
Upvotes: 2