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

Rails: Nested routes for associated model records

My main objective is to pass the profile id and the company id in with the params hash so that Update the join between the 2 models The models are setup up, where a profile belongs_to a company and a company has may employees(profiles) as shown in…
Aaron Dufall
  • 1,177
  • 10
  • 34
0
votes
1 answer

Nested Resources With Form For Gives: wrong number of arguments (1 for 0)

I'm trying to create an edit page for a nested route. The url is something like: http://localhost:3000/clients/2/notes/3/edit my routes.rb: resources :clients do resources :notes end In my edit controller: def edit @note =…
Noah Clark
  • 8,101
  • 14
  • 74
  • 116
0
votes
1 answer

resource available output parent resource rails 3.2

I have this in my routes.rb resources :users, :path => "/", :only => [:show] do resources :collections, :controller => 'users/collections' end Why can I access to collections resources from: http://localhost:3000/en/collections if this resouce…
0
votes
1 answer

Rails validations not working with habtm

for now i've got followings: model => User (name, email) has_and_belongs_to_many :trips model => Trip (dest1, dest2) has_and_belongs_to_many :users validates :dest1, :dest2, :presence => true model => TripsUsers (user_id, trip_id) (id =>…
Said Kaldybaev
  • 9,380
  • 8
  • 36
  • 53
0
votes
1 answer

Nested Resource Not Properly Destroyed on Dependent Destroy

I'm having issue with a youtube video being destroyed properly in a nested belongs_to has_one relationship between a sermon and its sermon video when using :dependent => :destroy. I'm using the youtube_it gem and have a fairly vanilla setup. The…
0
votes
2 answers

Rails: Is there a dry way to define methods that affect nested resources/models?

Just wondering if there's a better way to do the following: Users has_many Projects Projects has_many lists Lists has_many Items Certain users only have access to certain projects. But if a user has access to a project, then the user can access all…
Zhao Li
  • 4,936
  • 8
  • 33
  • 51
0
votes
3 answers

link to nested ressource in each

I have an Array of various ActiveRecord Objects which are Objects of different Models. One of them is called Team which is a nested ressource of Department: resources :departments do resources :teams end So when I use this in the array.each like…
davidb
  • 8,884
  • 4
  • 36
  • 72
0
votes
0 answers

Rails 3: Working with Heavily Nested Routes

I am looking for a better solution than what I currently have for my routes. They are deeply nested and there has to be a better solution for what I have done (thus far). This is what I have so far: namespace "api" do namespace "v1" do …
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
1 answer

How can I tell if eager loading is working?

So I've got a forum thread full of posts, and I want to eager load the users from the posts and those users roles, to reduce the total number of database queries (which seems to be the best way to do things) (to make things extra fun, forum and…
DVG
  • 17,392
  • 7
  • 61
  • 88
-1
votes
1 answer

Rails Child id using parent id

My issue is, when I am under the camper show page Current Camper URL: campers/1 and I go to click on to view the appointment it uses the camper_id for the appointment_id which is wrong so say if the camper_id is 1 it will use the appointment_id as…
-1
votes
1 answer

Rails form show extra button on iteration

This shows all the comments but it also shows an extra edit and delete button at the end. But when I reverse the order that is, I show Add comment after all the comments this bug seems to disappear. Anyone can point out what is happening? Also, I…
Souvik Das
  • 173
  • 1
  • 1
  • 8
-1
votes
1 answer

nested resources rails has and belongs to many

Sorry for the generic title, but I'm not sure how to phrase it better at the moment. I finally had some time to start picking up rails again and came across this issue as I was building my models: Essentially I have a parent resource that has two…
-1
votes
1 answer

Devise and shop creation

I would like to add a shop in the user registration with Devise. Let me explain: on the registration page, the user can check a box "create my shop now." If he checks, a form is displayed ans he can fill it. Then he submits the form, and User + Shop…
-2
votes
1 answer

In rails routes, nested resources is causing white screen

I have two models: Schedule and Project. Schedule belongs_To Project and Project has_one schedule. The routes for schedule and Project are nested like this: get 'projects/current', to: 'projects#show_current', as:…
1 2 3
24
25