smileymike
smileymike

Reputation: 263

Paths for nested resources

I am attempting to get rails routes paths via nested resources. I have looked under rails guides using link below:

http://guides.rubyonrails.org/routing.html#nested-resources

For instance,

  resources :users do
    resources :weekly_progress_charts
    resources :calories_journals
  end

i know and can use :users paths. What are the paths for calories_journals for instance?

for example, user_calories_journals_path does not get me a list of index via "users/1/calories_journals"

What is the correct rails's RESTFUL paths for calories_journals via selected user:

new edit update create destroy show index

Thanks in advance

Upvotes: 0

Views: 1568

Answers (2)

Wawa Loo
Wawa Loo

Reputation: 2276

You can call

user_calories_journals_path(user) OR
user_calories_journal_path(user, calories_journal)

It will show the index view in app/views/caleries_journals/index.erb.html OR app/views/caleries_journals/show.erb.html

EricM is right, use rake routes in the terminal to view all routes.

Notice that you could have resources :calories_journal also and it would work.

Upvotes: 1

EricM
EricM

Reputation: 754

Use rake routes to see the paths.

Upvotes: 0

Related Questions