Search code examples
ruby-on-railsruby-on-rails-4routeslink-to

Rails redirecting to a 'show' path when given another path


I have a custom route called "work_path" and when I try to access it I get this error

"Missing template portfolios/show" 

I am not trying to access the "show" view, but rather one named "work" (work.html.erb). I have no idea why it keeps trying to get me to the "show view"

My custom route

get 'portfolios/work' =>  'portfolios#work', :as => :work

Portolios Controller

def work
@portfolio = @portfolio.active
end 

The link I'm using:

<%= link_to "Work", work_path %>

I don't know why it's trying to redirect me.


Solution

  • You probably have also resources :portfolios in routes.rb above your custom route and that causes your problem. Switch these lines' positions.