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
2
votes
1 answer

Rails form - multiple nested routes undefined method '_path'

This app has the following models: Farm (has_many :crops) Crop (belongs_to :farm, has_many :issues) Issue (belongs_to :crop) Here are the routes: resources :farms do resources :crops do resources :issues end end I want a user to be…
2
votes
2 answers

Problem with routes in functional testing

I'm making a simple test project to prepare myself for my test. I'm fairly new to nested resources, in my example I have a newsitem and each newsitem has comments. The routing looks like this: resources :comments resources :newsitems do …
2
votes
1 answer

Is there a way to configure routes hierarchy in Python Flask-RESTFUL?

So let's say I have a few routes: api.add_resource(Customers, "/Customers") api.add_resource(Customer, "/Customer/") Now, the customer can have many things associated with it. Say for example, orders: api.add_resource(Customers,…
2
votes
1 answer

Nested Resources in show template

I'm having trouble understanding nested resources. There is a Service scaffold, and there is Symptom model. I wanted to be able to add the symptom_item string to the service scaffold. This is my current show template code: <% if…
pk36
  • 33
  • 5
2
votes
2 answers

Nested resources, undefined method nilClass

I am getting an error "undefined method " when I try to build a nested resource on action 'new' in rails 4.2 Here's my routes: devise_for :medics resources :patients, shallow: true do resources :consultations do resources :prescriptions end…
Carlos Gómez
  • 453
  • 7
  • 16
2
votes
1 answer

Rails 4 x paper_trail: filter versions by item_id with nested resources

In my Rails 4 app, I have the following models: class User < ActiveRecord::Base has_many :administrations, dependent: :destroy has_many :calendars, through: :administrations end class Administration < ActiveRecord::Base belongs_to :user …
2
votes
2 answers

Rails 4: ActionController::UrlGenerationError

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:…
2
votes
1 answer

How to build a nested route with Django REST Framework?

I want to build a simple API and picked up Django REST Framework (DRF). I want to minimize path nesting as Tom Christie (the author of DRF) pointed out to me. There are two models: Article and Comment. For these I want to build the following API…
JJD
  • 50,076
  • 60
  • 203
  • 339
2
votes
1 answer

Adding a namespace within a resource in rails

I'm trying to figure out how to do some routing in a Rails 4 app. This is my first question, so I'll do my best. I have accounts. A user can belong to multiple accounts. An account can have multiple "modules" enabled -- buyer / seller. resources…
2
votes
1 answer

How do I make friendly_id URLs for city and state like united-states/texas/austin

So I have 2 different links: united-states/texas/austin and: united-states/colorado/austin-14be76ea-77e2-4f0e-8540-0103ad72cd7a I want the second one to be simply: united-states/colorado/austin So how do I get friendly_id to stop creating unique…
Abram
  • 39,950
  • 26
  • 134
  • 184
2
votes
1 answer

Nested routes with Subdomain-fu

I have some standard nested routes in my app, and I want to implement subdomains using the subdomain-fu gem. So I'm currently doing this: example.com/stores/name_of_store/products/name_of_product and I want to do this: …
MikeH
  • 866
  • 1
  • 14
  • 26
2
votes
1 answer

Two resources using the same resource

Well, I didn't know how to title this. This was my best guess. Here's my problem: I'm having Issues and Reviews controllers. Both of them should have a Comments controller nested. Do I have to generate two separate scaffolds like icomment for the…
Mini John
  • 7,855
  • 9
  • 59
  • 108
2
votes
1 answer

Rails 4, strong parameters, nested resources, build and undefined method permit

I am unable to get rails 4, strong parameters to work with nested resources via build. Any suggestions would be very welcome. RSPEC shows me Creating Actions Creating an action Failure/Error: click_button "Create Action" NoMethodError: …
user894325
2
votes
1 answer

"Previous post" and "Next post" link in Show View (Nested Resources)

In my Application I want to add a "Previous Article" and a "Next Article" link in the bottom of my Article Show View. This is what I have so far but I get this error: undefined method `article_path' for…
Serge Pedroza
  • 2,160
  • 3
  • 28
  • 41
2
votes
2 answers

Variable calling in rails views

I just finished adding nested resource to my Ruby on Rails application. It was mostly will guessing, copying and pasting. Everything works now. But my concern is that while using url helpers, I had to use two different variable forms -- one with @…
B.I.
  • 706
  • 3
  • 9
  • 19