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
1
vote
1 answer

Laravel 5 - Nest Resource index method resource ID

I try to make a default controller base on the Laravel Restful Controller, and I'm block with the index method with Nested Resources. I have a route Route::resource('photos.comments', 'DefaultController'); and I need to get the photo_id in my index…
1
vote
1 answer

Rails - Include nested resource in model

I know how to include nested resources in controller render like this: render :json => @user, :include => {:profile} My doubt is: is it possible to do this in models? I tried many ways but it doesn't give me the user and his profile like this: { …
Seralto
  • 1,016
  • 1
  • 16
  • 30
1
vote
1 answer

"should get show" controller test failing for Nested resource

I have a User model and a Shoppingcart model where # user.rb class User < ActiveRecord::Base has_one :shoppingcart end and # shopppingcart.rb class Shoppingcart < ActiveRecord::Base belongs_to :user end and I have this in…
user2361174
  • 1,872
  • 4
  • 33
  • 51
1
vote
1 answer

Rails: Restrict Nested Resource Path

I'd like to keep my nested resources within the context of its parent. Here's my code below: routes.rb : resources :categories do resources :subcategories end migration : create_table "categories" do |t| t.string "name" end create_table…
1
vote
4 answers

Finds in Rails 3 and ActiveRelation

I'm trying to understand the new arel engine in Rails 3 and I've got a question. I've got two models, User and Task class User < ActiveRecord::Base has_many :tasks end class Task < ActiveRecord::Base belongs_to :user end here is my routes to…
TheDelChop
  • 7,938
  • 4
  • 48
  • 70
1
vote
1 answer

simple_form undefined method model_name 3 classes error

So I just Nested some resources that weren't Nested before and since I have been trying to fix all of the path references. The biggest issue I have been having is with the fact that there are 2 nested resources within a larger nested resource like…
ChiefRockaChris
  • 643
  • 5
  • 21
1
vote
1 answer

Ruby on Rails 4 - friendly_id with nested routed

I have a nested rout for toys and then toys will have reviews. The toys works fine with friendly_id but going to website.com/toys/toy-name/reviews/new brings up Couldn't find Toy without an ID My routes file looks like this resources :toys do …
Tom
  • 2,543
  • 3
  • 21
  • 42
1
vote
1 answer

ember-cli / pod: Nesting resources/templates

I have read various stackoverflow threads and other forum entries, but I am not able to figure out how to get nested resources/templates working using ember-cli 0.1.12 and pod structure. Versions: Ember : 1.8.1 (also tried 1.9.1) Ember Data :…
Manuel Reil
  • 508
  • 2
  • 10
1
vote
1 answer

Rails 4 shallow nesting UrlGenerationError, missing required keys

I'm trying shallow nested resources for the first time and having a little trouble with one my index routes. routes.rb resources :sites, shallow: true do resources :visits end The error I get is in my visits#show page's back button: <%= link_to…
uechan
  • 167
  • 8
1
vote
2 answers

param is missing or the value is empty

I have two models: Boards and Topics. I want to be able to add Topics to Boards. My nested resources are: resources :boards do resources :topics end My 'boards#show' action: def show @board = Board.find(params[:id]) @new_topics =…
dimitry_n
  • 2,939
  • 1
  • 30
  • 53
1
vote
2 answers

Nested resources - undefined method `comments_path'

I'm working on a forum app which has 4 models: Users, Boards, Topics and Comments. My routes are: resources :users do resources :boards ### 'boards' contain 'topics' resources :topics ### 'topics' are similar to 'posts' resources :comments…
dimitry_n
  • 2,939
  • 1
  • 30
  • 53
1
vote
2 answers

Rails 4 routes with simple_form and shallow nested resources

resources :accounts, shallow: true do resources :textnotes end Gives me account_textnotes GET /accounts/:account_id/textnotes(.:format) textnotes#index POST /accounts/:account_id/textnotes(.:format) …
Lut
  • 1,363
  • 1
  • 14
  • 30
1
vote
3 answers

Rails "NoMethodError" with sub-resources

I'm a newbie Rails developer who is getting the following error when trying to access the 'new' action on my CityController: undefined method `cities_path' for #<#:0x104606f08> Extracted source (around line #2): 1:

New…

Tchock
  • 65
  • 6
1
vote
1 answer

Nested Routing - current_user in URL

I have to models User and Blog. Their respective urls are: test.com/u/user_name # User test.com/blogs # Blog I'm trying to achieve that the blogs are nested to the user which created it. E.g. test.com/u/user_name/blogs and for an article…
Mini John
  • 7,855
  • 9
  • 59
  • 108
1
vote
2 answers

Nested Resource testing RSpec

I have two models: class Solution < ActiveRecord::Base belongs_to :owner, :class_name => "User", :foreign_key => :user_id end class User < ActiveRecord::Base has_many :solutions end with the following routing: map.resources…
TheDelChop
  • 7,938
  • 4
  • 48
  • 70