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

How to map a resource to more than one helper in rails?

I have a Profile model, which is inherited by a Customer and Vendor model. Profile has_many :posts. When I do form_for [ @profile, @post ] do |f| Instead of callind profile_posts_path, form_for will actually call customer_posts_path or…
Francesco Boffa
  • 1,402
  • 1
  • 19
  • 35
1
vote
1 answer

ROR: Nested Resources: NoMethodError

In my application teams are created to solve a challenge. Once the team is created, members can join that team. Everything works when creating the challenge -> the team, but when it comes to adding the team member that is when I receive this…
1
vote
0 answers

Issue with rails nested resource form

For some reason I can't get this to work. Offering has many Responses and Response has many Replies I'm trying to display the Reply form in _response.html.erb (see below) and it's throwing this error when I go to…
Pavan Katepalli
  • 2,372
  • 4
  • 29
  • 52
1
vote
0 answers

Right way to handle deeply nested resources in Rails

So I have four models, A, B, C, and D that I associate with has_many and belong_to. I want to have a nested route formation for D. D belongs_to A, B and C and there is no case that it can be otherwise. However when creating a nested resource for…
eytanfb
  • 443
  • 4
  • 17
1
vote
1 answer

Unable to display image from database when using nested resource

Problem displaying image from database I am working on a website which allows both customers and account users to upload their pictures. Using a recipe provided in the book Agile Web Development with Rails, I have managed to make it work for the…
1
vote
1 answer

Capybara + Rspec Nested Route

Having some difficulties with my Capybara RSPEC testing where I have a nested resource. Here's the error I receive: 1) Photo pages visit photo path Photo can be visited after FactoryGirl create records ←[31mFailure/Error:←[0m ←[31mvisit…
Mitch Nick
  • 302
  • 2
  • 8
1
vote
1 answer

How to find the correct nested resource when dealing with many to many relationships in Rails 3

Bear with me as I'm a Rails noob. I have a basic league system. League -> Seasons -> Divisions -> Teams. I would like my Divisions and Teams to belong to any number of seasons. My models are as follows... class Season < ActiveRecord::Base …
joero4
  • 210
  • 3
  • 8
1
vote
1 answer

How to render form with nested and single resource

I have this routes resources :childs do resources :draws end resources :draws How can I write a single _form.htm.erb for adding and editing draws? I mean, from new_draw_path I would use form_for(@draw) and then select the child with f.select…
1
vote
1 answer

How to set a controller action similar to 'new' in a nested resource

I have a nested resource defined in routes.db: resources :accounts do resources :transactions do end I would like to create a route that is similar to 'new', but the action would be new_transfer, which would allow me to handle a special type of…
Cagilla
  • 13
  • 4
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

Nested resources no route matches error

I am trying to get a basic nested resource path to work but am currently getting the following error: No route matches {:action=>"show", :controller=>"stores"} In my view I have the following links: <% if current_user %> Hello <%=…
1
vote
1 answer

backbone.js bootstrapping nested resources

If a user has bookmarked, or shared the following URL, how should my one page backbone.js application (uses Backbone.Router) go about retrieving the required data in order to render the complete…
1
vote
2 answers

Where should a page that creates multiple resources live?

I have a Presentation Model which I create in the usual way through a form. The Presentation Model has two nested resources: a Recording Model and a SlideDeck Model: class Presentation < ActiveRecord::Base has_one :recording has_one…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
1
vote
1 answer

Rails 3 Create nested resource "No route matches" error

I am new to Rails and am trying to create a child record in a nested resource. My routes.rb file contains this: resources :sports do resources :teams end My teams_controller.rb file contains this for the create def: def create @sport =…
1
vote
2 answers

How can I create an account resource with default parameters at the same time as creating a user resource?

Apologize for the easy question. I have nested resources resources :users do resources :accounts end and I want to have an account for a new user create in the background when a user is created. I tried UserController def create @user…
ajbraus
  • 2,909
  • 3
  • 31
  • 45