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 resources issue

those are my routes: resources :forums, :shallow=>true do resources :topics, :shallow=>true do resources :posts end end within topics/show.html.erb I added a form to leave a post (Post is like a comment for a Topic) <%= form_for…
socksocket
  • 4,271
  • 11
  • 45
  • 70
0
votes
1 answer

Nested Resource Sad Path Renders blank comment

I have a comment resource nested in a post resource. def create @post = Post.find(params[:post_id]) @comment = @post.comments.build(params[:comment]) @comment.ip = request.remote_ip if @comment.save redirect_to…
DVG
  • 17,392
  • 7
  • 61
  • 88
0
votes
1 answer

Using Namespace nested resources with MongoMapper EmbeddedDocument with form_for

I'm submitting a form that is sending in a child resource's id value for both the child resource and it's parent resource's id. I don't know how to get the form submission to stop duplicating the child id as the parent resource's id. Technology…
idStar
  • 10,674
  • 9
  • 54
  • 57
0
votes
1 answer

Rails 3.2 how to make scoped resources

I am using Rails 3.2 and am attempting to make a scoped nested resource (not sure if this is the right terminology). I have several groups and I want each group to have its own set of pages, like…
user1002119
  • 3,692
  • 4
  • 27
  • 30
0
votes
2 answers

creating nested resource

I have a question that bothers me every time I face the same situation. How to create a nested resource.. I have the following repo https://github.com/abhishekdagarit/app-e-commerce.git You can clone the repo and create the dabtabase to see the…
0
votes
3 answers

Routing error when using nested resources

I have a Post and Comment models. Comment belongs to a Post, and it is nested under Post in routes. Comments are posted from Posts#show. My routes look like this: resources :posts do resources :comments, only: [:create, :edit, :update,…
Mohamad
  • 34,731
  • 32
  • 140
  • 219
0
votes
1 answer

Rails: Nested resources

The following path throws up an error: = link_to 'Subscribers', user_subscribers_path(current_user) undefined method `user_subscribers_path' for <#:0x007f9b240b3148> I am not sure why. I have defined my routes as follows: resources :users,…
Karan
  • 14,824
  • 24
  • 91
  • 157
0
votes
2 answers

How do I get my create action to work for both a nested & non-nested resource?

So I have two models Topic, Client. A Client has_and_belongs_to_many :topics, and a Topic has_and_belongs_to_many :clients. Basically, what I want to happen is...when someone goes to my Topic#index, depending on how they got there (i.e. either via…
0
votes
2 answers

Rails - DRY'ing up new/edit pages in nested resources

My new and edit pages for multiple levels of nested resources all worked fine when I had a flat resource structure. Since nesting resources for the purpose of making a more logical structure, these pages have been a bit broken. I have a single form…
bdx
  • 3,316
  • 4
  • 32
  • 65
0
votes
1 answer

Safe redirect to nested resource in Rails

I recently added the Brakeman gem to my Gemfile and had to see, that I should use :only_path => true to make it more secure. But i'm using a nested resource and don't know exactly how, here is the part from my Controller. if…
Daniel Schmidt
  • 11,605
  • 5
  • 38
  • 70
0
votes
1 answer

Skip Before Filter for Nested Resource

I am currently working on a Rails 3.2 application in which I have two controllers. One is campaign and the other one is posts. Both of them are having a before_filter. Please have a look at the controller and routes below : Campaigns Controller…
Smoke
  • 1,052
  • 1
  • 10
  • 24
0
votes
2 answers

Rails nested routing to html id

given a blog style application: #models class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end #routes.rb map.resources :posts do |posts| posts.resources :comments end how do I…
Blake Chambers
  • 505
  • 1
  • 5
  • 14
0
votes
1 answer

HTTP POST request sent via curl against REST server looses JSON parameters

I created a REST server with Rails that manages Users and associated Comments. Here is the routes configuration. resources :users do resources :comments end In the controller I only need actions to query and create Comments. The exchange format…
JJD
  • 50,076
  • 60
  • 203
  • 339
0
votes
1 answer

Nested Resources vs/and/or CanCan?

I am using Rails 3 with the CanCan gem. The models Users and Networks are a has_many :through => Roles. This part works fine. Currently I am using CanCan so that on the /networks page it will only display a network if a users has access to it. This…
dewyze
  • 979
  • 1
  • 7
  • 21
0
votes
1 answer

Rails app generating wrong :id in parent controller

I am creating a very basic rails app for the first time with 2 resources, Departments(depts) and Members. I believe I have used nested resources correctly, but for some reason after running rails server, the :id for the parent resource is not being…
1 2 3
24
25