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 access nested resource parameters from parent controller in Ruby on Rails?

I started writing an app which reviews books, articles etc(model name: Piece ) and has the option to review chapters or smaller sections (Sections, Subsections, and Subsubsections models) I want to be able to generate a general overview of the Piece…
1
vote
1 answer

How to change default path/url in routes in Rails 4

I'm working on a simple reservation application. Here are my routes resources :users do get 'reservations', on: :member end resources :listings do resources :reservations end When I try to make a reservation, action reservations#new takes me…
Natalia
  • 11
  • 1
1
vote
1 answer

rails nested resource: Move from child/show.html to parent/show.html using link_to or other Not Working

I have a phones resource nested within a user one, and each have independent views. I can use link_to to get to the nested resource, phones, but am unable to go back in the opposite direction and link back to user views from within a phone view. I…
W. Wuffley
  • 69
  • 1
  • 6
1
vote
1 answer

Rails - How to export nested resources to CSV in Rails?

I am trying to export some data to CSV in Rails 4. I have two models: Excursions and Inscriptions. One excursion has many inscriptions and one inscription belongs to one excursion. I have my nested routes defined this way: resources :excursions…
F404
  • 144
  • 1
  • 12
1
vote
0 answers

Define Model Factory with nested resource in Laravel

I have Articles with translations and I am trying to created a seeder for it. I have a model factory to define a simple Article as follows: $factory->define(\App\Article::class, function () { return []; }); And…
Hector Ordonez
  • 1,044
  • 1
  • 12
  • 20
1
vote
2 answers

Rails, Nested Resource, Update Action

I'm trying to have a simple button to update for each Comment through a submit form. Here is my View code: <% @comments.each do |comment| %> <%= form_for comment, url: article_comment_path(comment.article, comment), method: :patch do |f| %> …
gitastic
  • 516
  • 7
  • 26
1
vote
1 answer

Ruby on rails. Form for a nested model in a different view

I've been battling this for a while now and I can't figure it out. I have a user model using devise. Users can upload songs, and add youtube videos etc.. I'm trying to let users add/delete songs and videos from the devise edit registrations view.…
Rob Hughes
  • 876
  • 2
  • 13
  • 32
1
vote
2 answers

Rails 4 nested resources Creating new records undefined method create_association

undefined method `create_school' for #< User:0xb4e407a0 > This is my create action @school = current_user.create_school(school_params) In my model definitions user has_one profile profile has_many schools
fugee ohu
  • 57
  • 7
1
vote
1 answer

Rails JQUERY Toggle with Nested Resources

I'm trying to figure out how to toggle a "finish" action with nested resources in rails. For whatever reason I can't get it to do what I want. I keep getting 'Couldn't find List without an ID'. Which makes sense but I can't configure it so that it…
Mark Hustad
  • 169
  • 1
  • 14
1
vote
1 answer

Rails 4 Nested Resources Error with 3 models

Error: ActiveRecord::RecordNotFound Couldn't find Option with 'id'= This is happening when I add a link to the options show.html.erb to get all the registrations for that option. In order to get the event id and the option id, I'm adding the…
1
vote
2 answers

Rails 4 x paper_trail: keep track of versions after item is destroyed

This is a follow up question on Rails 4 x paper_trail: filter versions by item_id with nested resources. ————— CONTEXT FROM PREVIOUS QUESTION In my Rails 4 app, I have the following models: class User < ActiveRecord::Base has_many…
1
vote
1 answer

Rails Cocoon Gem - double nested resource

I have an Article, which has a nested resource of Image Gallery. An Image Gallery has a nested resource of Image Gallery Image. I have set up my params for Articles as such: params.require(:article).permit( :featured_image, :title, :description,…
1
vote
2 answers

undefined method `permit' for "**output omitted**":String

Updated: I have a link_to set up for deleting an object that is a nested resource. Prior to destroy, I have a method that checks for the instance of that object based on object_params, but the params sent keep raising undefined method 'permit' for…
1
vote
1 answer

Rails 4 deep nesting with routing

Here is my route.rb: resources :books, :path => "librairie" do resources :chapters, shallow: true end resources :chapters do resources :titles, shallow: true end resources :titles Here's my models: class Book <…
cagliostro
  • 182
  • 1
  • 10
1
vote
1 answer

Rails 4: can I deep nest a shallow resource within another shallow resource?

In my Rails 4 app, there are five 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:…