Questions tagged [nested-routes]

Nested routes allow to capture relationship in your routing.

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

462 questions
1
vote
1 answer

rails 4 Controller namespace

route -> namespace :admin do get '' => 'home#index' end class Admin::ApplicationController < ActionController::Base layout 'admin' class Admin::HomeController < Admin::ApplicationController When i first open just /, and then open /admin/…
Alex808
  • 106
  • 1
  • 10
1
vote
1 answer

Rails link_to path variable convention?

Sorry, this is a naive question. I have a nested resources depth 2 levels. resources :programs do resources :questions do resources :answers end end So for the index,edit, etc pages to work I need to modify the link_to attribute…
Clone
  • 919
  • 4
  • 11
  • 22
1
vote
2 answers

Ruby on Rails undefined method `products_path' routing issue

It's been awhile since I've worked in Rails and I'm having some issues with setting up my routes properly. Any help would be greatly appreciated. URL: http://localhost:3000/admin/products/new Error: undefined method `products_path' for…
1
vote
2 answers

Rails named routes. When should you use them?

A simple question. I'm wondering what the proper way to do this is. Say you have this: Event Venue.has_many :events Performer.has_many :events And for routing: resources :venues do resources :events end resources :performers do resources…
Binary Logic
  • 1,529
  • 2
  • 17
  • 19
1
vote
0 answers

Rails nested routing match

I am new to rails and have a tricky routing question. I have a resource with a nested collection that maps to the controller of the type for the nested collection. However the name of the collection does not map to the controller which I want to…
1
vote
1 answer

Multiple nested routes to the same controller. Couldn't find XYZ without an ID

I'm refactoring my application to use 1 level deep nested resources everywhere, it's a JSON-only API. Here's a trimmed version of my routes.rb: resources :measurements, only: [:index, :show] do resource :tag_node, controller: :physical_nodes,…
Benjamin M
  • 23,599
  • 32
  • 121
  • 201
1
vote
1 answer

Nested routes and no route matches

I have three resources - users, lists and items. I just nested lists under users and updated my links accordingly, but I am getting two errors from rspec which are a complete mystery to me. Everything worked before I nested the routes. I'm a total…
Daniel Friis
  • 444
  • 3
  • 23
1
vote
1 answer

Can't manage to deal with nested resources

I have such problem: I don't need to nest all resources, because I need only two action. First - show all reports related with 1 website. Second - show all reports. When I rewrite code in routes.rb like this: resources :websites do member do …
MID
  • 1,815
  • 4
  • 29
  • 40
1
vote
2 answers

Correcting invalid Resource Routes in Rails

One thing I noticed when working with nested resource routes in Rails is that it is technically possible for a user to visit a route where the child resource exists (and is therefore displayed correctly), but the id for the parent resource…
Ajedi32
  • 45,670
  • 22
  • 127
  • 172
1
vote
1 answer

Nested resources link from index not working

Okay so I have a post index and would like to link it to my slide index, but for some reason i keep getting this error No route matches {:controller=>"slides"} when i link with this <%= link_to 'Show Slides', post_slides_path(@post) %> If i use…
Serge Pedroza
  • 2,160
  • 3
  • 28
  • 41
1
vote
1 answer

View's testing indicates 'No route matches' for nested resource

I have a Training model that's nested under a devise User model. /config/routes.rb devise_for :users, path: 'u' resources :users, only: ['index','show'], shallow: true do resources :trainings end > rake routes new_user_session GET …
João Daniel
  • 8,696
  • 11
  • 41
  • 65
1
vote
1 answer

Rails: Nested Resources routes not working

I have the following routes defined: resources :employees do resources :questions member do get :results end end One of the routes (rake routes) for the above resources prints this: new_employee_question GET …
kapso
  • 11,703
  • 16
  • 58
  • 76
1
vote
1 answer

Path helpers for nested controllers / namespaces

I have routes structure: namespace :admin do resources :currencies end rake routes output: admin_currencies GET /admin/currencies(.:format) admin/currencies#index POST /admin/currencies(.:format)…
1
vote
1 answer

Are deeply nested polymorphic resources worth the effort?

I am at the point in my development that I am thinking that deeply (>1) nested resources are not worth the effort. I have something like this: resources :first-level do resources :comments resources :second-level do resources…
1
vote
2 answers

nested namespace route going to wrong controller

Using Rails 3.0.7, I'm creating an API for our app, and I have this setup: routes.rb namespace :api do namespace :v1 do match "connect" => "users#login", :via => :post match "disconnect" => "users#logout", :via => :post …