nested-routes

What objects should be passed to a link_to with triple nested route?

五迷三道 提交于 2019-12-08 10:50:38
问题 What objects should I pass to my link_to for a triple nested route? I want to retrieve the exercise show page. show.html.erb - workouts <%= link_to exercise.name, plan_workout_exercise_path(???) %> routes.rb resources :plans do resources :workouts do resources :exercises end end workouts_controller.html.erb def show @workout = Workout.find(params[:id]) end I have attempted the following, but it doesn't feed the right ID to the right model. <%= link_to exercise.name, plan_workout_exercise_path

drf-nested-routers RuntimeError('parent registered resource not found')

孤人 提交于 2019-12-06 20:45:28
I am attempting to utilize the package drf-nested-routers to created nested routes within my API. I've attempted to follow alongside the documentation ( https://github.com/alanjds/drf-nested-routers ) as well as read through multiple Stackoverflow threads in hopes to figure out this issue. I would like to create a single NestedSimpleRouter. Here is what I have so far inside of my routers.py file: from django.urls import path, include from rest_framework.routers import DefaultRouter from rest_framework_nested import routers from api_v1.viewsets import DeviceViewSet, BreadcrumbViewSet router =

Aurelia How do I use a Child Router and dynamics child routes

て烟熏妆下的殇ゞ 提交于 2019-12-06 15:38:17
Trying to use a child route in Aurelia. Can't seem to get my head around the workings of nested routes. Are all routes derived from the root of the app or relative to location of the current router? Why wont my route-href work in this example? I have a route in this router named screen and it does have an :id parameter screens/list.ts @inject(Router) export class ScreensList { heading; router; screens: any[]; constructor(router){ this.heading = 'Child Router'; this.router = router; this.screens = [ { id: 1, name: 'my screen' }, { id: 2, name: 'my other screen' } ] router.configure(config => {

ruby-on-rails - Problem with Nested Resources

▼魔方 西西 提交于 2019-12-06 14:01:10
问题 I have a Problem with Nested Resources. 2 Models User => has_many :stuffs Stuff => belongs_to :user routes.rb map.resources :stuffs map.resources :users, :has_many => [:stuffs] When i call /users/1/stuffs it presents me the Stuff for the corresponding User. but i got this also when i call /users/2/stuffs. It should return 0 "Stuffs" but it dont work. MySQL Query from Server SELECT * FROM `stuffs` rake routes stuffs GET /stuffs(.:format) {:action=>"index", :controller=>"stuffs"} POST /stuffs(.

ruby-on-rails - Problem with Nested Resources

天涯浪子 提交于 2019-12-04 20:33:13
I have a Problem with Nested Resources. 2 Models User => has_many :stuffs Stuff => belongs_to :user routes.rb map.resources :stuffs map.resources :users, :has_many => [:stuffs] When i call /users/1/stuffs it presents me the Stuff for the corresponding User. but i got this also when i call /users/2/stuffs. It should return 0 "Stuffs" but it dont work. MySQL Query from Server SELECT * FROM `stuffs` rake routes stuffs GET /stuffs(.:format) {:action=>"index", :controller=>"stuffs"} POST /stuffs(.:format) {:action=>"create", :controller=>"stuffs"} new_stuff GET /stuffs/new(.:format) {:action=>"new"

Ember JS transition to nested routes where all routes are dynamic segments from a view

╄→гoц情女王★ 提交于 2019-12-04 01:21:19
We are writing an application using EmberJS. However we are still new with this framework and we're having a hard time resolving some of what may seem to be straight forward. The model is pretty simple, there are 3 models: Queue, Task, and Image. We are using dynamic URI segments for all routes and routes for these models are nested in the form: :queue_id/:task_id/:image_id. The routes are configured this way: App.Router.map(function() { this.resource('queue', {path: ':queue_id'}, function() { this.resource('task', {path: ':task_id'}, function() { this.resource('image', {path: ':image_id'}); }

RESTful API routes design: nested vs. non-nested

只愿长相守 提交于 2019-12-03 15:50:07
问题 My question is about the advantages of nesting resources when building URLs for API purposes. Consider the following two alternatives for accessing an employee resource: /api/employees?department=1 # flat Vs. /api/departments/1/employees # nested Now consider the task of developing a general purpose library to access REST resources from an API. If all routes were flat, such a REST wrapper library would only need to know the name of the resource being accessed: store.query('employees',

RESTful API routes design: nested vs. non-nested

こ雲淡風輕ζ 提交于 2019-12-03 05:20:40
My question is about the advantages of nesting resources when building URLs for API purposes. Consider the following two alternatives for accessing an employee resource: /api/employees?department=1 # flat Vs. /api/departments/1/employees # nested Now consider the task of developing a general purpose library to access REST resources from an API. If all routes were flat, such a REST wrapper library would only need to know the name of the resource being accessed: store.query('employees', {department_id:1}) => /api/employees?department=1 However, if we were to support nested routes, this wrapper

Rails 3 - Nested resources and polymorphic paths: OK to two levels, but break at three

左心房为你撑大大i 提交于 2019-12-03 00:04:13
I'm trying to do a simple family reunion site with: "posts", "families", "kids", and "pictures". Ideally I'd like the routes/relationships to be structured this way: resources :posts do resources :pictures end resources :fams do resources :pictures resources :kids do resources :pictures end end In the models I have the necessary " belongs_to " and " has_many " relationships set between fams and kids . Fams , kids , and posts all are defined with "has_many :pictures, :as => :imageable " while pictures are defined as: belongs_to :imageable, :polymorphic => true When trying to do link_to "Edit"

Naming params of nested routes

﹥>﹥吖頭↗ 提交于 2019-12-01 09:14:05
resources :leagues do resources :schedule end This generates: leagues/:id leagues/:league_id/schedule/:id How can I keep the league ID from changing param names? So it'll be: leagues/:id leagues/:id/schedule/:schedule_id No, please do not do this. The reason for it being this way is that it provides a common interface for nested resources across every single application. By making it different in your application, you're effectively going "against the grain" of Rails. Rails has a strict set of conventions that you should stick to. When you stray from this path, things get messy. However, if