V
V
Vadim2017-07-26 16:42:46
Ruby on Rails
Vadim, 2017-07-26 16:42:46

How to create such a route in RoR?

essence: I want to display articles of a specific user.
Actually, I see this way out:
create such a route /articles/users/1
so that it points to the users(user_id) action in the articles controller
or is it possible in another way?
ps: I just know RoR)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
N. Bekseitov, 2017-07-26
@Vadim-55

The easiest way is nested resources

resources :users do
  resources :articles
end

Get paths
/users/:user_id/articles/
/users/:user_id/articles/(:id, new, edit)

V
Vadim, 2017-07-26
@Vadim-55

thanks. like what you need. I will continue to dig

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question