Questions tagged [nested-resources]

In REST, nested resource is a web resource composing another. Its reference is built over the reference of another web resource.

Definition

In REST-style architecture , a resource is simply a source of information, the one you want to expose. The resource is referenced by a global identifier such as an URI. When you deal with information structure such as composition, you’ll use nested resources. The reference of the embedded resource is then built over the reference of the composite resource.

For instance, a blog post http://example.com/posts/1 owns several comments http://example.com/posts/1/comments.

374 questions
3
votes
1 answer

Rails 4: routing for has_many :through association

I have three models: class User < ActiveRecord::Base has_many :administrations has_many :calendars, through: :administrations end class Calendar < ActiveRecord::Base has_many :administrations has_many :users, through:…
3
votes
1 answer

Minitest a controller for a nested resource

I want to minitest a nested resource controller and I keep getting the error below: 1) Error: PostsControllerTest#test_should_show_post: ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"posts",…
3
votes
3 answers

Spring Data Rest - Include nested resource in _embedded

I'm developing a Spring Boot Application for a shopping list. For this I use Spring Data Rest to export my entities through a REST API. My Architecture looks like this I have a ShoppingItem: public class ShoppingItem { @Id @GeneratedValue private…
Yannic Bürgmann
  • 6,301
  • 5
  • 43
  • 77
3
votes
1 answer

Undefined method each with nested resources

I'm trying to follow Ryan Bates Polymorphic association tutorial in order to put some comments to my site. The thing is I have nested resources: #Nesting Resources resources :users do resources :photos do resources :comments …
Gibson
  • 2,055
  • 2
  • 23
  • 48
3
votes
1 answer

rails best practices for nested recourses - show (parent) vs. index (child)

I have the following nested resources in my rails 3 app. resources :calendars do resources :events end What is the recommended url/path for displaying (list or calendar) events for a specific calendar? Should I use the show method of the…
ajporterfield
  • 1,009
  • 2
  • 10
  • 23
3
votes
1 answer

How to use will_paginate with a nested resource in Rails?

I'm new to Rails, and I'm having major trouble getting will_paginate to work with a nested resource. I have two models, Statement and Invoice. will_paginate is working on Statement, but I can't get it to work on Invoice. I know I'd doing something…
Sue Petersen
3
votes
2 answers

Loading nested resources via ajax (rails)

I've got routes that look like this: resources :projects do resources :tasks end Which gives you a URL like so: URL/projects/14/tasks/3 The models define that: project has_many :tasks task belongs_to :project Right now, when a user clicks on the…
nathan
  • 514
  • 1
  • 7
  • 20
3
votes
1 answer

Who can explain the FindResource/LoadResource/LockResource?

I load a module(exe/dll) by LoadLibrary and get a pointer of a binary resource in it . Microsoft note that should use three steps : use FindResource return HRSRC use LoadResource with that HRSRC and return HGLOBAL use LockResource lock the HGLOBAL…
wenxibo
  • 171
  • 2
  • 6
3
votes
1 answer

nested routes and form_for and NoMethodError

As the error message stated below, I do not use "user_profiles_path" as plural because I defined "resource :profile" in nested resource. NoMethodError in Profiles#new Showing…
3
votes
1 answer

Correct route for a singular nested resource

I have 2 resources, one being a nested resource of another: parent_resource and child_resource. This gives me the following routes: somesite.com/parent_resources/14 somesite.com/parent_resources/14/child_resources/1 However there is only ever going…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
3
votes
3 answers

Nested Resources without ID of parent in the route

I have two resources: resources :users do resources :cars end The association is: A user can have many cars A car belongs to a user When doing that kind of nested resourcing, I get urls like: /users/:id/cars/new My question is: If it makes…
Hommer Smith
  • 26,772
  • 56
  • 167
  • 296
3
votes
1 answer

how do I specify nested CanCan authorizations with non-standard relationship names?

I'm using Devise for authentication and CanCan for authorization. the goal I have two models: User and Sponsorship, where Sponsorship provides a has_many :through relationship between user-as-sponsor and user-as-client. I want to configure…
fearless_fool
  • 33,645
  • 23
  • 135
  • 217
2
votes
2 answers

Different views when nesting resources in Rails

I am using Rails 3.2.1. Is it possible to use different views when using nested resources? i.e. profile/comments post/comments. Let's say you want both pages to look completely different. Is there a way to do this without overriding render in every…
Arjan
  • 6,264
  • 2
  • 26
  • 42
2
votes
1 answer

Check the current parent controller of a nested resource

I have a nested resource in users: resources :users do resources :reservations end In my controller actions i can get the current controller name by using controller.controller_name. So in the user show action the controller.controller_name…
Harm de Wit
  • 2,150
  • 2
  • 18
  • 24
2
votes
1 answer

active_admin, nested routes and custom view

i just start playing with active_admin, I have 2 resources: class Category < ActiveRecord::Base validates :name, :presence => true has_many :auctions end and class Auction < ActiveRecord::Base belongs_to :category end under app/admin I…
Mattia Lipreri
  • 953
  • 1
  • 16
  • 30