FAQ Database Discussion Community


nested resources rails has and belongs to many

ruby-on-rails,has-and-belongs-to-many,nested-resources
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 nested resources....

ember-cli / pod: Nesting resources/templates

templates,ember.js,routes,nested-resources
I have read various stackoverflow threads and other forum entries, but I am not able to figure out how to get nested resources/templates working using ember-cli 0.1.12 and pod structure. Versions: Ember : 1.8.1 (also tried 1.9.1) Ember Data : 1.0.0-beta.12 Handlebars : 1.3.0 (also tried 2.0.0) jQuery : 1.11.2...

Rails nested Resources not working in controller

ruby-on-rails,associations,nested-resources
I have this nested resource: resources :services do resources :users do put "assign" => "services#users#assign", as: :assign end end My form contains this: <%= button_to 'submit', service_user_assign_url(service.id, abstractor.id), method: :put %> this generates the following url, which looks fine to me: http://localhost:3000/services/1/users/2/assign and the following is in my services controller:...

Laravel 5 - Nest Resource index method resource ID

php,laravel,laravel-5,laravel-routing,nested-resources
I try to make a default controller base on the Laravel Restful Controller, and I'm block with the index method with Nested Resources. I have a route Route::resource('photos.comments', 'DefaultController'); and I need to get the photo_id in my index method. But so fare, I only get {photos}. public function index(Request...

RAILS 4: problems with 'delete' button

ruby-on-rails,delete,nested,nested-resources
I have a nested resource, comments like so.... resources :microposts do member do get :upvote, :undo_upvote end member do get :follow, :unfollow end resources :responses do member do get :upvote, :undo_upvote end resources :comments end end I have a delete button on the comments index page.... <div class = "Comment"...

simple_form undefined method model_name 3 classes error

ruby-on-rails,ruby,routes,nested-resources
So I just Nested some resources that weren't Nested before and since I have been trying to fix all of the path references. The biggest issue I have been having is with the fact that there are 2 nested resources within a larger nested resource like so: Users->Photos->Comments On my...

Rails - Include nested resource in model

ruby-on-rails,nested-resources
I know how to include nested resources in controller render like this: render :json => @user, :include => {:profile} My doubt is: is it possible to do this in models? I tried many ways but it doesn't give me the user and his profile like this: { id: 1, name:...

Nested Resources in Rails views

ruby-on-rails,ruby,nested-resources
I know there are many articles on Rails nested resources and I went through a lot of them but nothing answers my question. I have 3 models: user, group and micropost. User subscribes to groups, each having a number of microposts. All the association are in place and working fine....

ReNesting Resource Routes in Rails

ruby-on-rails,routing,haml,member,nested-resources
So I just made one of my objects a nested resource of my user object. Now all of my links don't work and my index won't show. I am getting the error: /views/photos/index.html.haml where line #8 raised: No route matches {:action=>"show", :controller=>"photos", :id=>nil, :user_id=>nil} missing required keys: [:id, :user_id] with...

New nested resource with link_to

ruby-on-rails,nested-resources
I have this route: resources :projects do resources :services resources :contacts resources :title_abstracts resources :parcels resources :leases resources :documents end this is in my Projects View to add a new Contact to the Project: new_project_contact_path(@project) The url produced is: http://localhost:3000/projects/15/contacts/new And the Contacts Controller: def new @project = Project.find(params[:project_id]) @contact...

Ruby on Rails 4 - friendly_id with nested routed

ruby-on-rails,ruby-on-rails-4,friendly-id,nested-resources
I have a nested rout for toys and then toys will have reviews. The toys works fine with friendly_id but going to website.com/toys/toy-name/reviews/new brings up Couldn't find Toy without an ID My routes file looks like this resources :toys do resources :reviews, except: [:show, :index] end The reviews controller has...