Nested routes allow to capture relationship in your routing.
Questions tagged [nested-routes]
462 questions
2
votes
1 answer
rails - how to make nested route with ancestry
I have a single model:
class Page < ActiveRecord::Base
has_ancestry
validates :slug, :name, uniqueness: true, presence: true
before_validation :generate_slug
def to_param
slug
end
def generate_slug
self.slug…

jazzis18
- 213
- 2
- 13
2
votes
1 answer
Capture ParentID param in nested resources
I would like to capture the parent Id param (foreign key) before a new child record is saved.
I have the two setup as nested resources in the routes file and the link to the new child controller action shows the parent ID nested correctly.
When I…

Dercni
- 1,216
- 3
- 18
- 38
2
votes
1 answer
Specs failing for api with nested routes
I'm working on adding an api to a ruby on rails todo list project as a learning exercise and I'm having problems testing some specs that use nested routes.
I'd like to show a list of uncompleted tasks when the /lists/1/ endpoint is used, but when I…

Tien Yuan
- 323
- 1
- 2
- 9
2
votes
0 answers
Managing layout and templates in angularJS
This seems to be a very common problem.
Currently I have a login form and few pages on my front end and a back end.
My single route file looks like this -
Front End
/login
/about
Back End
/dashboard
/manageuser
/settings
Now the problem which I am…

Trialcoder
- 5,816
- 9
- 44
- 66
2
votes
1 answer
How to properly avoid nesting routes more than 1 level deep in Rails
I'm having a hard time conceptualizing the best way to set up the resources for this project.
Here are my current routes:
resources :customers do
resources :jobs
end
resources :jobs
resources :rooms
resources :memos
resources :appliances
…

Dustin James
- 575
- 9
- 21
2
votes
1 answer
Remove unnecessary parameter from nested resource controller in Laravel 4.x
I am developing an API through Laravel using Resource Controllers which are linked through the routes.php file. See the example below:
// API routes
Route::group(array('prefix' => 'v1'), function() {
Route::resource('users', 'UserController');
…

Robin
- 132
- 7
2
votes
2 answers
How to customize RESTful Routes in Rails (basics)
I have read through the Rails docs for Routing, Restful Resources, and the UrlHelper, and still don't understand best practices for creating complex/nested routes. The example I'm working on now is for events, which has_many rsvps. So a user's…

Lance
- 75,200
- 93
- 289
- 503
2
votes
0 answers
Rails 4 form helper fails on nested routes
I've been banging my head on this issue for about 2 hours now. This makes no sense to me. I'm trying to to write a simple form helper that is 3 level nested. (I'm aware that 3 level nests are not recommended, but just roll with me here for a…

R. Yanchuleff
- 323
- 1
- 15
2
votes
1 answer
How to nest collection routes?
I use the following routes configuration in a Rails 3 application.
# config/routes.rb
MyApp::Application.routes.draw do
resources :products do
get 'statistics', on: :collection, controller: "statistics", action: "index"
end
end
The…

JJD
- 50,076
- 60
- 203
- 339
2
votes
1 answer
Form_For undefined method path
I am experimenting with nested resources:
My routes:
resources :conversations do
resources :replies do
resources :comments
end
end
I was able to get the form for replies to work with the conversation, but now I'm adding the…

Nathan McKaskle
- 2,926
- 12
- 55
- 93
2
votes
1 answer
Backbone.js + Rails 3 urls and collections with nested routes
I'm trying to create a new application with both Rails and Backbone.js, but there are quite a few nested relations that are making it rather difficult.
On the Rails side, I'm using a HABTM relationship between Ingredients and Allergens. I'm trying…

doremi137
- 31
- 2
2
votes
3 answers
Rails namescoped model object without module prefix route path
i have problem little bit with Rails router and form generator.
My application have namespaced modules for models and controllers. Module is used to easier abstraction to another projects.
I using in routes.rb scope method instead namespace, because…

rado
- 2,413
- 1
- 18
- 15
2
votes
1 answer
How to use the slug from Friendly_id in a nested route?
I am having a hard time making the slug from Friendly_id in a nested route when editing and creating? the routes look great for show.
http://0.0.0.0:3000/test/tester2
This is the URL I am getting when i try to edit tester2…

T. Weston Kendall
- 349
- 6
- 17
2
votes
0 answers
Rails acts_as_commentable_with_threading and nested routes
I have the following route:
resources :organisations do
resources :comments, only: [:create, :destroy]
resources :events do
resources :comments, only [:create, :destroy]
end
end
As the documentation for AACWT example suggests, I try…

Ashley Bye
- 1,752
- 2
- 23
- 40
1
vote
1 answer
Rails 3 destroy method respond_with JS using nested resources
I'm having this annoying problem with Rails 3 (ruby 1.9.2) and nested resources. In my routes:
resources :lists do
resources :items, only: [:destroy, :update, :create]
end
My ItemsController has respond_to :json at the beginning and #destroy…

rikas
- 482
- 4
- 25