Question about recommended way to access a controller from a route given `no-controller-access-in-routes` rule
See original GitHub issueAccessing this.controllerFor()
property inside setupController/resetController
method in a route class raises a lint error ( no-controller-access-in-routes
). Is that the expected behavior and if yes, how can one access another controller in a route class.
I am accessing the controller to setup route transition redirect like this (I could opt to use query params or disable the lint on the affected LOC but is there an option to access another controller in a route)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Question about recommended way to access a controller from ...
Question about recommended way to access a controller from a route given `no-controller-access-in-routes` rule.
Read more >Exception is raised when 2 controller routes and a named ...
Exception is raised when 2 controller routes and a named action route is used. i have this webapi controller: using Microsoft.AspNetCore.
Read more >MVC route rule to default to Home controller when no ...
The simplest option is to use static URLs in your route config, like ContactUs rather than using {action} (which can literally match anything)....
Read more >Express Tutorial Part 4: Routes and controllers - MDN Web Docs
The code first imports the Express application object, uses it to get a Router object and then adds a couple of routes to...
Read more >Rails Routing from the Outside In - Ruby on Rails Guides
How to construct your own routes, using either the preferred resourceful style or ... How to declare route parameters, which are passed onto...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also hitting up against this: the rule and the Ember guides for Storing and Retrying Transitions are at odds. 🙃
I am upgrading ember from version 3.20 to 3.24.
The no-controller-access-in-routes rule recommends not using a controller within a route, unless the reference to the controller is in the setupController/resetController hooks, as can be seen in the link below:
https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-controller-access-in-routes.md
However we have some willTransition actions that access the controller, and even the ember documentation, there is an example of willTransition accessing the controller, as can be seen in the link below:
https://api.emberjs.com/ember/3.26/classes/Route/events/willTransition?anchor=willTransition
this eslint rule is correct? If the app needs access to the controller from willTransition, how to handler this question?