gespinha
gespinha

Reputation: 8487

routes as: path variable not working

I have the following route

  resources :projects do
    collection do
      get 'svdbf', to: 'projects#new', as: 'otherstuff'
    end
  end

and I am trying to make this link work on the view

<%= link_to 'Other Stuff', otherstuff_url %>

But it's returning the following rails error:

undefined local variable or method `otherstuff_url'

What am I doing wrong?

Upvotes: 0

Views: 95

Answers (2)

Zepplock
Zepplock

Reputation: 29145

Please run rake routes from the console. That will give you a full list of routes as well as a list of helper functions available to you.

Also try otherstuff_path instead og otherstuff_url

Upvotes: 0

Elvn
Elvn

Reputation: 3057

Based on the rake routes output you posted, a working path would be

<%= link_to 'Other Stuff', otherstuff_projects_path %>

Upvotes: 1

Related Questions